Benafsh Yalda
Benafsh Yalda

Reputation: 396

How to query database using LINQ to bring data from database based on array of months in ASP.Net MVC 5?

I have a table like blow image:

enter image description here

How do I write a LINQ query to bring records of Jan, Feb, March from the table?

my query:

 var query = (from c in db.TheMonthlyDelivery  select c).AsQueryable();

I am new to LINQ please help me.

Upvotes: 0

Views: 1113

Answers (1)

Rahul Singh
Rahul Singh

Reputation: 21795

Try this:-

int[] months = { 1, 2, 3 };
var query=  db.TheMonthlyDelivery.Where(x => months.Contains(x.Date.Month));

Upvotes: 1

Related Questions