.net - C# searching through lists -
In the following code I am using 3 foreach statement. I'm just trying to populate a list when a list of items matches another, but those who do not match should also be added. So I was thinking that there is an easy way to do the following.
list & lt; T & gt; DS = new list & lt; T & gt; (); // virtual foreach (var b in template.bs) {list & lt; BD & gt; TempList = new list & lt; BD & gt; (); Foreign (BD BD in BD BD) {Boolean found = false; Forresh (DV DV In Items) (if (BDC C == DVC C) {found = true; TempList.Add (new BD () (// populating});}} If (! Found) tempList.Add BD ()) {// populating});}}
ds The relationship between
and is not clear, but it seems that your inner end is actually a left external participant:
list & lt; T & D; ds = new list & foreach in temp. (); // templates in var b) {var newBDs = BD items in BD in BD I d D. is included in D. D is equal to DVC, in J.DefaultFacti () Select DV == Faucet? Not match (BD): match (BD, DV); list Let's do something with
, we can convert b
in template
of For B BD
to bb
with dv
s in items
. We then put default IfEmpty ()
in null
to dv
, if no match is available, then we will To use which projection method is called: Make a new BD
based on Not match ()
unmatched BD
, and BD
based on a new BD
and DV
.
This complete query will be newBDs
, which is IEnumerable & lt; BD & gt;
. We can buffer that sequence into tempList
or make something more useful with it.
Comments
Post a Comment