Reputation: 23
I want to get the list of users (UserId) who celebrate their birthday in the months of February and August
I have already tried these:
public ActionResult Test()
{
var Model = db.Users.Where(u => u.Birthday.Value.Month == 02);
public ActionResult Test()
{
var Model = db.Users.Where(u => u.Birthday.Value.Month == 02).ToList();
I expected a list of UserId
that celebrate birthday in the months of February and August.
Upvotes: 0
Views: 217
Reputation: 117
try this:
var model = db.Users.Where(u => u.Birthday.Value.Month == 02).Select(c=>c.UserId).ToList();
that shoud give you the list with the UsersID ( for february) if you want both months try:
var model = db.Users.Where(u => u.Birthday.Value.Month == 02 || u.Birthday.Value.Month == 08).Select(c=>c.UserId).ToList();
Upvotes: 1
Reputation: 126
Try This
var Model = db.Users.Where(u => u.Birthday.Month == 02 || u.Birthday.Month == 08).ToList();
Upvotes: 1