简体   繁体   中英

How to get multiple records of different employee in same date using EF

I have a table where I store multiple records,of multiple employees,I want a query that return total records of all employee in one date just and ignore all other occurrence which may b in different dates.

         id     username        date             cnic.     amount
         1.          AkA.      12_09_16.        1234.      2000
         2.         AkA         same            1234.      20
         3.         Zzz.        Same.           234.       5000
        4.         Zzz          same.           234.       300
        5.         AkA.         13_09_16.       1234.      250

C# format,not sql

As I've understood correctly you can try to use the following code:

public IList<string> GetUserNames(DateTime specificDate)
{
   var userNames = Entries.Where(x => x.Date == specificDate)
                       .Select(x => x.UserName)
                       .Distinct()
                       .ToList();
   return userNames;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM