Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

searching by multiple values....

$
0
0

Hi,

I'm trying to see what the best query would be to do a search in a table.  The table is as follows:

ID, title, startDate, endDate

User adds in multiple searches so there might be records like the following in search criteria:

13, "Group1", '8/9/2018', '12/10/2019'

13, "Group1", '', '6/5/2020'

15, 'Registered', '11/19/2018', '',

17, 'Waiting Approval', '', ''

There's an "OR" and "AND" option the user can choose...if they choose "AND", I want to get all records from the table that meet all of the above criteria where the ID and title matches exactly and the dates for those ID are in between the start and end date.  If start date is specified but not the end date, disregard the end date but start date must match and enddate can be anything in the table.  Likewise for the endDate.   If query is for "OR", I want to get all the records that match any of these search criteria.  There's also a UserID in the table for which to group these records by.  

What's the best way to write this query?  The search data is stored in a dataTable.


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>