I'm bonking my head against the wall trying to resolve this.
I've got three tables - Widgets, Users, and Subscriptions. I have a one-to-many reference set up between Users and Subscriptions since users can have multiple subscription, and a many-to-one between Widgets and Users.
What I'm trying to do is populate a gridview of widgets. Widgets have (only) one user, and those users may or may not have a subscription that's in the same category as that widget. So I've got
Widgets has a category_ID and user_ID (the owner)
Users have a user_ID and a name
Subscriptions have an expiration date, category_ID, and user_ID
Now before in LINQ to SQL I was doing something like
from c in dataContext.Widgets
let sub_days_left = (from d in dataContext.subscriptions
where d.category == c.category
&& d.user_table.user_ID == c.user_table.user_ID
days_left = sub_days_left == null ? 0.0 : (sub_days_left - DateTime.Now).TotalDays
So I'm converting this all to Entity Framework and obviously TotalDays can't be used. So I'm trying to figure out how to accomplish this. I don't want to do an .AsEnumberable or .ToList() so that I can use Linq
View Complete Post