Click here to Skip to main content
15,072,735 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
         I want to retrieve the agencyName added between the date ranges arrivalFDate  & arrivalTDate . How do I add a linq query having multiple where conditions.  ArrivalDate is field of InternationalArrivals. 

Like the same way as : SELECT * FROM InternationalArrival where AgentName=@agentName, ArrivalDate IN BETWEEN (@arrivalFDate , @arrivalTDate )

              string agentName = result[0];

                DateTime arrivalFDate = DateTime.ParseExact(result[1], "dd/MM/yyyy", CultureInfo.InvariantCulture);

                DateTime arrivalTDate = DateTime.ParseExact(result[2], "dd/MM/yyyy", CultureInfo.InvariantCulture);

                List<InternationalArrival> intarrivals = null;

                using (var _context = new SQLHELPSEntities())


                    intarrivals = _context.InternationalArrivals.Where(t => t.AgentName.Contains(agentName)).OrderBy(a => a.AgentName).ToList();  ++++++++++WHERE CONDITION OF DATERANGE FIELD CONTAINS where ArrivalDate In BETWEEN arrivalFDate   &  arrivalTDate .

What I have tried:

I have tried but error I have tried but error I have tried but errorI have tried but error
Updated 22-Dec-17 2:15am
Richard MacCutchan 22-Dec-17 6:49am
What error?
Richard Deeming 22-Dec-17 12:29pm
Rather than pointlessly repeating the same text four times to "cheat" the minimum character requirements, you could have shown us what you've tried, and what error you got.

You can add multiple conditions in where scope. Trying using this.

intarrivals = _context.InternationalArrivals.Where(t => t.AgentName.Contains(agentName) && t.ArrivalDate >= arrivalFDate && t.ArrivalDate  <= arrivalTDate).OrderBy(a => a.AgentName).ToList();

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