I am new to LINQ,
I want to generate a list of objects from my dbcontext where a certain field is set to true.
This is what I have so far, but I am getting an error about a select?
using (var db = new dbContext())
{
return (from s in db.sims.Where(x=>x.has_been_modified == true) select x).ToList();
}
EDIT:
//Returns a list of entries which where marked as edited in the sim managment database
private List<String> GetUpdatedEntries()
{
using (var db = new dbContext())
{
return db.sims.Where(x => x.has_been_modified).ToList();
}
}
select s
, not x
and this will work. (because you do from s
)
shorter way
return db.sims.Where(x => x.has_been_modified).ToList();
For your Edit
the method return type should be a List<Sim>
, not a List<String>
This will work
return db.sims.Where(x=>x.has_been_modified).ToList();
s
as context and selected x
, changing to select s
should work alsoToList
at the end of every queryIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With