Monday, December 26, 2022

Removing elements from var LINQ ASP.NET

 var exceptionList = 

                 allData.AsEnumerable().Where(a => dtOpenVacancy.AsEnumerable().Select(q => q.Field<string>("disciplinename")).Contains(a.Field<string>("discipline")) && dtOpenVacancy.AsEnumerable().Select(q => q.Field<string>("institutename")).Contains(a.Field<string>("institute")) && dtOpenVacancy.AsEnumerable().Select(q => q.Field<int>("cadreid")).Contains(int.Parse(ddlCadreType.SelectedItem.Value))).ToList();

                

                ViewState["dt2"]= allData.AsEnumerable().Except(exceptionList.AsEnumerable()).CopyToDataTable();


Use Tolist somewhere

or you can use removeall from List.

No comments:

Post a Comment