dino2dy
dino2dy
CC#
Created by dino2dy on 10/12/2023 in #help
❔ Access 2 properties from validationRule
Hi everyone, I have a valdiation rule on textbox ID when entering a new user. A user inputs ID which is a unique string every person has. I have a validation rule that checks the ID against the db column ID to see if it is unique and hasn't been inputted before. This all works. The issue is that you can also edit an existing user. The user that is edited will throw the validation error for ID because the validation rules still checks the ID against the DB. I wish to access the newRow property from the VM in the validationRule so that the rule would only throw an error if the newRow flag is true. How can I do this?
7 replies
CC#
Created by dino2dy on 12/16/2022 in #help
❔ Linq group by with multiple columns for the outer and then 1 other column for the inner group
Lets say I have a list of class Car. It has properties Id, Model, Year, Age,CarCode. A carCode is unique for a model but is not for all models. I want to group by Model and Year together and then group that grouping by Age and then for each Agegroup in each model and year group send Model, Age, and list<string>CarCodes to a method which will update a db table with those CarCodes. I found some pieces of code online but couldnt get anything to give me the thing I need.
var grouped = bla
.GroupBy(l => new { l.sreSif, l.sreSerija})//group by two things
.Select(y => new { Element = y.Key, })
.GroupBy(f => f.Element.sreSerija)//this will become the outer grouping

//THEN I TRIED
var consolidatedChildren =
from c in bla
group c by new
{

c.sreSif,
c.sreSerija,
} into gcs
from g in gcs
group g by new
{
g.sreIsplatio
};
var grouped = bla
.GroupBy(l => new { l.sreSif, l.sreSerija})//group by two things
.Select(y => new { Element = y.Key, })
.GroupBy(f => f.Element.sreSerija)//this will become the outer grouping

//THEN I TRIED
var consolidatedChildren =
from c in bla
group c by new
{

c.sreSif,
c.sreSerija,
} into gcs
from g in gcs
group g by new
{
g.sreIsplatio
};
this line of thinking did not work What I want
var carModelYearGroupList=GroupBy CarLIst(Model, Year)
var carAgeGL= groupBy carModelYearGroupList(key.Age)

Parallel.ForEach(carModelYearGroupList, new ParallelOptions { MaxDegreeOfParallelism = 10 }, (car) =>
{
Parallel.ForEach(carAgeGL, new ParallelOptions { MaxDegreeOfParallelism = 10 }, (ca) =>
{
UpdateDb(Model m, Age a, List<string> carCodes);
});
});
var carModelYearGroupList=GroupBy CarLIst(Model, Year)
var carAgeGL= groupBy carModelYearGroupList(key.Age)

Parallel.ForEach(carModelYearGroupList, new ParallelOptions { MaxDegreeOfParallelism = 10 }, (car) =>
{
Parallel.ForEach(carAgeGL, new ParallelOptions { MaxDegreeOfParallelism = 10 }, (ca) =>
{
UpdateDb(Model m, Age a, List<string> carCodes);
});
});
3 replies