C
C#2y ago
Natty

Ez LINQ Help

I am trying to get a list of Values from the Cells where the Columns table Number is equal to 0. I think I am close, but not quite there:
var cashFlowCells = db.CashFlows.Include(x => x.Cells).Where(x => x.Columns.FirstOrDefault().Number == 0).OrderByDescending(x => x.Id).FirstOrDefault().Cells.Select(x => x.Value).ToList();
var cashFlowCells = db.CashFlows.Include(x => x.Cells).Where(x => x.Columns.FirstOrDefault().Number == 0).OrderByDescending(x => x.Id).FirstOrDefault().Cells.Select(x => x.Value).ToList();
4 Replies
Saber
Saber2y ago
are you trying to get all the values, or only for the first CashFlow Do you only want the values, or do you want additional information
Natty
NattyOP2y ago
Specifically, just the 2017, 2018, etc all the way to end Value(s). Originally i was doing a loop of stepSize += 4 but the thing is the other data will have differing stepSizes. Yet, I know that the info I want will always be in the 0 column.
Saber
Saber2y ago
why not just db.Cells.Where(c => c.Column == 0).Select(c => c.Value)
Natty
NattyOP2y ago
hm probably because my tables aren't quite set up correctly tbh Wonder if i could just add Cells table to my db context and if that would work then... (Testing it now) Yup, I think that did it.... Cheers mate.
Want results from more Discord servers?
Add your server