I have the following classes. I have a object var
of Description class. I want to select Balance related to the Client provided in the var
object u
You could try this:
var balance = (from a in context.Accounts
join c in context.Clients on a.UserID equals c.UserID
where c.ClientID == yourDescriptionObject.ClientID
select a.Balance)
.SingleOrDefault();
Or - if you only have the DescriptionID
:
var balance = (from a in context.Accounts
join c in context.Clients on a.UserID equals c.UserID
join d in context.Descriptions on c.ClientID equals d.ClientID
where d.DescriptionID == yourDescriptionID
select a.Balance)
.SingleOrDefault();
(Or FirstOrDefault()
or ToList()
or Sum()
? Because your model would allow that clients/descriptions are related to multiple accounts ...)