c# - LINQ: Get the Parent object properties and a single child property as a flat structure -
Here is a list of addresses contained in the original object of the branch have not been defined in the branch or in addresses And I need to get a flat hierarchy or these branch and address.
c P.Addresses in var x CurrentBranchList of p = where p.ScheduledForDeletion == false where c.ScheduledForDeletion == false & amp; Amp; C.AddressTypeId == 3 Select new {BranchId = p.BranchId, name = p.Name, address = (C == empty)? "": C. Address 1 + "" + c. Address 2, city = (C == empty)? "": C. Whistle, stat = (c == empty)? 0: c.StateId}; The above is what I have tried, but if the address is missing then I do not get any information about the branch ... I am still trying to find out how this link Running with In SQL I would have just been in two tables to get that table.
Can someone help me on this ... I'm sure this is a very easy thing thanks. PS I know it is very similar () but it is that a child is always present
edited - Working solution was The following code that seem to work for me I can not be based on the database for the source because edit objects memory contained in CurrentBranchList and persistence in a single operation is done.
equals God c.EntityId ur on p.EntityId X = CurrentBranchList.SelectMany join c p CurrentBranchList (b = & gt; b.Addresses) where p.ScheduledForDeletion == select false UrkDefaultIfEmpty () U new {BranchId = p.BranchId, name = P Knam, n = (u == null)? "": U.Address1 + "" + u.Address2, city = (U == empty)? "": U.City, State = (U == empty)? 0: u.StateId}; Thank you for your help. Those links really helped me understand what needs to happen.
I also tried the solution of Daniel Brinkner and said that seems more elegant and requires less typing :-) Duo scenarios I seem to be working in a try
There is thus
var xx = CurrentBranchList.SelectMany (b looks = & gt; .. B.Addresses Choose default effects (). (a = & gt; new) {branch IID = B. Branch ID, Name = b. Name, address = (A == blank)? "": A. Address 1 + "+ + A. Address 2, city = (A == empty)?" ": A. City, state = (An == empty)? 0: a.State Id}));
IQueryable & lt; Branch & gt; Branches = gatebank (); Var Results = Breaches SelectMany (b = & gt; b.Addresses. DefaultIfEmpty () Select (a => New {branch = B, address = a}));
Comments
Post a Comment