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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -