I have a database, that includes a one to many foreign key, eg
Table {shop
[Id]
...}
Table {user
[Id]
[Shop_id]
[Archived]
}
I also have a method as below
public IEnumerable<shop> GetShopDetails(int shopId)
{
var foo = (from s in context.Shops
where s.Id = shopId
select s).ToList();
return foo;
}
As a consequence of this, it will return all users for that shop. Most of the time I only really want the users that are Not Archived.
Is there a way of writing this into the one statement, so I can pass in, say a second parameter of includeArchived, and use that to determine if I return all users, or just those that are active.
At present, I can make it work either by addind a method to my shop object that returns a subset of users, or I can load the shop, get its id, and then create a seperate collection of users that contain the appropriate fk, but either method seems a little clunky to me.