[Solved] linq to sql select does not working on dateTime


It looks like you are trying to get a count of all users who registered on a certain day. If so, I think you are best off using the group keyword to group together all users by registration date. You can then create a new anonymous type to contain by the date, and the count, like so:

var Counts = (from d in db.Users
             // filter down to only users registered between FromDate and Now
             where (d.RegistrationDate.Value >= FromDate 
                 && d.RegistrationDate < DateTime.Now)
             // Group all users together by Date of registration (assuming 
             // RegistrationDate is a DateTime? field)
             group d by d.RegistrationDate.Value.Date into date
             // Get a new anonymous type that contains the date and the number
             // of users registered on that date
             select new { Date = date.Key, Count = date.Count() } );

solved linq to sql select does not working on dateTime