This is untested, but I think it's pretty close: var groupEntries = from you in db. Users where user. Id == user_id join gu in db.
GroupUsers on u. UserId equals gu. UserId join g in db.
Groups on gu. GroupId equals g. GroupId join ge in db.
GroupEntries on u. GroupdId equals ge. GroupId into ges from ge in ges.
DefaultIfEmpty(new GroupEntry { EntryId = 0, GroupId = g. GroupId }) select ge I don't think you need to use into unless you're planning to do some further processing, such as DefaultIfEmpty() And notice that the second overload of DefaultIfEmpty() allows you to enter a custom default value. So, you can create a new GroupEntry object and assign the values you want for each property (or leave properties blank).
This is untested, but I think it's pretty close: var groupEntries = from you in db. Users where user. Id == user_id join gu in db.
GroupUsers on u. UserId equals gu. UserId join g in db.
Groups on gu. GroupId equals g. GroupId join ge in db.
GroupEntries on u. GroupdId equals ge. GroupId into ges from ge in ges.
DefaultIfEmpty(new GroupEntry { EntryId = 0, GroupId = g. GroupId }) select ge; I don't think you need to use into unless you're planning to do some further processing, such as DefaultIfEmpty(). And notice that the second overload of DefaultIfEmpty() allows you to enter a custom default value.So, you can create a new GroupEntry object and assign the values you want for each property (or leave properties blank).
Thank you very much Dan. This is a much more straightforward query. I'm falling into some trouble later in the code behind.My current function is expecting an IEnumberable object type through which it can iterate.
Right now, in my foreach loop, after the query, I'm getting the "Unsupported overload used for query operator 'DefaultEmpty'" error. On a curiosity-related side note, if you use the "into" keyword in linq, does it necessarily create a subquery at the lower db layer? – Corey O.
May 30 '10 at 17:04 Corey, is this a LinqToSql query? – DanM May 30 '10 at 21:52 Yessir. The underlying DB is an MSSQL 2005 server.
– Corey O. May 30 '10 at 22:43 You should be able to see exactly the query being sent to SQL Server by hovering over groupEntries in the debugger. – DanM May 30 '10 at 23:31 Negative.
Instead, what I see is something like "entries | {System.Data.Linq. DataQuery}". In my actual code, I have a function that is something like "public static IEnumerable GetEntriesByUserID(int user_id) {}" This is where the actual query is spelled out.
Even if I insert a "throw Exception("debug point")" line before the return statement, I still get the same error later in my foreach loop, I assume because of delayed evaluation: "Unsupported overload used for query operator 'DefaultEmpty'" . Can you tell me anything about the nature of this error? – Corey O.
May 30 '107 at 5:08.
Set this to see all queries issued. MyDC. Log = Console.
Out; //setup to load the GroupEntries property of each group DataLoadOptions o = new DataLoadOptions(); o. LoadWith(g => g. GroupEntries); myDC.
LoadOptions = o; //query to get the groups IQueryable groupQuery = from g in myDC. Groups where g.GroupUsers. Any(gu => gu.User.
UserID == user_id) select g.
Regarding the last two sections, I must admit that this is a little above my understanding. You are using anonymous functions (lambda expressions) here? Would you be willing to give a quick explanation of what's going on here, or a quick link that might help to explain it?
Thanks in advance. – Corey O. Jun 1 '10 at 17:23.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.