score:2
if (comments) users will want to search partially on dates, then honestly: the best thing to do is for your code to inspect their input, and parse that into a range query. so; if you see "12/04"
, you might parse that into a day (in the current year, applying your choice of dd/mm vs mm/dd), and then do a range query on >= that day and < the next day. similarly, if you see "2021"
, your code should do the same, but as a range query. trying to do a naïve partial match is not only computationally expensive (and hard to write as a query): it also isn't very useful to the user. searching just on "2"
for example - just isn't meaningful as a "contains" query.
then what you have is:
(var startinc, var endexc) = parserange(searchterm);
samuraisqueryable = samuraisqueryable.where(
x => x.createddate >= startinc && x.creationdate < endexc);
Source: stackoverflow.com
Related Query
- How to search date in a dynamic query using IQueryable in c#
- Creating a dynamic query using IQueryable
- How can I write the following code more elegantly using LINQ query syntax?
- How to construct IQueryable query using Linq when I just need count without reading all documents in Document-Db database?
- How to dynamic add filters to a LINQ query against an Odata Source in C#
- How to build dynamic query with Where and OR using Expression
- How do I search a dynamic object IEnumerable<dynamic> using a dynamically built lambda expression?
- How can we express the following code using query expression?
- how to create dynamic linq query based on search criterias
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How to best handle a search query that includes 0 to 3 parameters/filters but using a single LinQ to Entities expression
- how to create dynamic query using Lambda expression
- How to query a date range from a varchar column using LINQ
- Search by Date using Linq query
- How to get the Sum of specific property using dynamic query
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- How to get Date Month and Year Number using dataSet.Tables query
- How to implement dynamic search functionality using C# and Linq?
- How to set order of IQueryable query based on another list using linq in c#?
- How to effectively do dynamic query using LINQ against a Azure Cosmos Document DB SQL API?
- How do I find the text within a div in the source of a web page using C#
- How do I apply OrderBy on an IQueryable using a string column name within a generic extension method?
- How to Select Min and Max date values in Linq Query
- How to avoid Query Plan re-compilation when using IEnumerable.Contains in Entity Framework LINQ queries?
- How to retrieve last 5 records using LINQ method or query expression in C#
- Trim() a list of strings using dynamic query language to produce a trimmed IQueryable<string>
- How do I get the latest date from a collection of objects using LINQ?
- How to query a nested list using a lambda expression
- How to Convert LINQ Comprehension Query Syntax to Method Syntax using Lambda
- How to use GroupBy using Dynamic LINQ
More Query from same tag
- How to filter by enum from string in LINQ C#
- Selecting columns in DataLoadOptions
- How to Connect to SQL Server using LINQ to SQL?
- Checking if all items in one generic collection exist in another using custom comparison delegate
- Unable to cast object of type 'System.Int16' to type 'System.String' - AsEnumerable().ToDictionary
- Grouping by anonymous v.s. grouping by non-anonymous
- Counting Word Frequency (most significant words) in a String, excluding keywords
- How to fetch attribute value under elements/elements in xml using LINQ
- Rewrite into a SortedList
- Getting records from many to many relationship with their order in the joining table using EF?
- For each using linq how to use else
- Getting error in LINQ query to sqlite
- How to solve issue "Could not translate expression ...into SQL and could not treat it as a local expression."
- lambda expression for OR condition in Linq to entity
- convertion issue with DateTime being null in a LINQ query
- How to find all id and autopaste as parameter using linq?
- How to get the names of nodes with Linq
- Extracting information from xml using XDOCUMENT and LINQ (C#)
- Linq pass an Indexer as IEnumerable.Select selector
- MVC Linq Query with dynamic column name in WHERE clause
- Flatten LINQ subselect so 1..n becomes one row
- LINQ and SQL performance issue when working with Membership
- how to parse xml like this using linq to a object
- Why is var Int32 not List<Int32> in this example
- Convert a string[] to its associated array of enums
- How to print numbers using LINQ
- How to query object with nested lists using linq?
- Cannot implicitly convert type decimal? to OrdersList, are you missing a cast
- how do i build dynamic linq queries at runtime using strings?
- Selecting object with collection of objects from many-to-many relationship