asp.net mvc - Adding two lists together with duplicates C# MVC -
i have 3 lists of product entity keys want put one big list. want duplicates present want determine product mentioned in final list.
i trying use .union removes duplicates final list.
//union selector results iqueryable<productmodel> unionproducts = categoryproducts.union(attoptproducts); if (manufacturerproducts != null) unionproducts = unionproducts.union(manufacturerproducts); if (brandproducts != null) unionproducts = unionproducts.union(brandproducts);
any appreciated.
use concat
instead of union
keep duplicates:
iqueryable<productmodel> unionproducts = categoryproducts.concat(attoptproducts); if (manufacturerproducts != null) unionproducts = unionproducts.concat(manufacturerproducts); if (brandproducts != null) unionproducts = unionproducts.concat(brandproducts);
Comments
Post a Comment