Click here to Skip to main content
15,896,486 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
Posted
Updated 22-Dec-17 2:15am
Comments
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.


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

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