Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi want to return a list of areas which dont appear in the current list of data;

I have two list of data, once which contains a list of areas;

A second one which contains the data

i want to query the data list and return only where area does not exist in the list

What I have tried:

This is my code

public static List<string> CheckprocessSubmisson(string department, string searchDate)
      {
          var itemsnotListed = new List<string>();

          var listofProcess = getListofProcesses(department);

          var startDate = DateTime.Parse(searchDate).AddHours(7);
          var endDate = startDate.AddHours(24);

          using (var smpEntities = new SMPEntities())
          {

              var test1 = (from x in smpEntities.Checks_Records.Where(x => x.DateLogged >= startDate
                                                                        && x.DateLogged < endDate
                                                                        && x.Checks_Records_Department.Equals(
                                                                        department))
                           select x).ToList();

              foreach (var item in listofProcess)
              {
                  itemsnotListed = (from x in test1.Where !(from i in x=
              }
          }

          return null;
      }
Posted
Updated 10-Jan-18 1:07am
Comments
Karthik_Mahalingam 9-Jan-18 9:51am    
what is listofProcess type ?
what is area?
question is not clear, Use Improve question to add more info to the question.

Sir the Demo code given bellow .For the match element Contains but for negative ! operator is used
 var exceptionList = new List<string> { "exception1", "exception2" };

   var query = myEntities.MyEntity
                         .Select(e => e.Name)
                         .Where(e => !exceptionList.Contains(e.Name));
 
Share this answer
 
Dependig on situation you may use: Except(TSource)[^] or Intersect(TSource) Method [^] or Any(TSource) Method[^]
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900