It's rarely correct to use join in L2E/L2S Use associations/navigation properties instead Off the top of my head (may require some tweaking): var QueryResults = from project in ProjectSet let p = project.Contacts. FirstOrDefault(c => c. IsPrimary) let s = project.Contacts.
FirstOrDefault(c => c. IsSecondary) group project by new { Primary = p, Secondary = s } into g select new EmailDetails { PrimaryContact = g.Key. Primary, SecondaryContact = g.Key.
Secondary, Projects = from proj in g select new ProjectDetails { Project = proj, Region = proj. Region, ProjectItems = proj. ProjectItems } }.
It's rarely correct to use join in L2E/L2S. Use associations/navigation properties instead. Off the top of my head (may require some tweaking): var QueryResults = from project in ProjectSet let p = project.Contacts.
FirstOrDefault(c => c. IsPrimary) let s = project.Contacts. FirstOrDefault(c => c.
IsSecondary) group project by new { Primary = p, Secondary = s } into g select new EmailDetails { PrimaryContact = g.Key. Primary, SecondaryContact = g.Key. Secondary, Projects = from proj in g select new ProjectDetails { Project = proj, Region = proj.
Region, ProjectItems = proj. ProjectItems } }.
Thanks. This has got me much closer to what I need. Primary and secondary contacts, and projects have some associated entities I need access to.
A contact has a navigation property to an Organisation object and a navigation property for a list of phone numbers. A project has a reference to a Region object and a list of ProjectItems. How can I efficiently get this data into memory?
I'm usng EF3.5 so I believe lazy loading isn't an option? Sorry if I'm a bit off with the terminology, I'm still learning the ins and outs of this framework. – Luke CK Sep 15 '10 at 13:12 Easy way to do this in 3.5 (and 4) is to change EmailDetails.
Projects to IEnumerable (i.e. , a view or edit model, not an entity) and project onto that. I'll update the example.
– Craig Stuntz Sep 15 '10 at 13:33 Thanks. That works but is there a way to do this that doesn't require the creation of ProjectDetails and ContactDetails classes? I'd like to be able to access the region and ProjectItems via the navigation properties.It feels like it shouldn't be necessary to create new data structures just to be able to access related objects.
– Luke CK Sep 15 '10 at 14:03 What makes you think you can't access these properties? Did you try what I suggested? Anonymous types work just as well if you don't like creating POCOs.
– Craig Stuntz Sep 15 '10 at 14:13.
It's rarely correct to use join in L2E/L2S . Use associations/navigation properties instead.
NoteYou can't specify a one-to-one, zero or one-to-zero or one, and many-to-many relationship by using the data designer in LightSwitch. Deletion Behavior SettingsThe following table describes the options that you can set to govern what happens when a user tries to delete a record that's part of a relationship. Some options aren't available for certain kinds of relationships.
On Delete Behavior ValueDescriptionCascade deleteWhen a "Table1" is deleted, delete all related "Table2" instances. Restricted"Table1" can't be deleted if related "Table2" instances exist.
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.