score:2
Accepted answer
I like this one (overlapping dates)! In general the formula is:
var dateFrom = ;// start of week
var dateTo = ; // end of week
var events = rep.Get()
.Where(e => e.Start <= dateTo && e.End >= dateFrom)
.AsQueryable();
Because you need things contained by the range, starting in the range and extending out, starting before the range and ending in, and starting before and ending after the range.
But if you need to handle a nullable
.End
then maybe more like:
var dateFrom = ;// start of week
var dateTo = ; // end of week
var events = rep.Get()
.Where(e => e.Start <= dateTo && (e.End ?? e.Start) >= dateFrom)
.AsQueryable();
(very) rudimentary mockup to help visualize:
Source: stackoverflow.com
Related Query
- Check if date range is within another date range for fullcalendar.io display
- Group by date range , count and sort within each group LINQ
- linq - how do you do a query for items in one query source that are not in another one?
- Check dates fall within range using Linq
- LINQ: Group by Date Range within 5 minutes
- Group By Date within specific range
- Elegant way to check if a list contains an object where one property is the same, and replace only if the date of another property is later
- Using LINQ how can I check for an instance of a number in one array, in another array?
- Check if a string within an array appears in another string array in LINQ?
- Linq repeat every nth element for a given range within a List<T>
- Check null condition for string date conversion to DateTime inside object
- Linq produce a list of missing records for a given date range
- source code for LINQ 101 samples
- LINQ query to check if a postcode is within a range of starting and ending postcodes?
- how to check Date range overlap in LINQ
- How to total quantity based on date range from another table?
- Run LINQ query with date range check in C# with correct date format
- How to check List for value in a specific range of values in .NET
- How to get items that were effective within a date range in linq
- LINQ to SQL check for Datetime is null or less then current date
- How can I take a list of dates, and remove any that are within 1 minute of another date in the list with LINQ?
- C#: get database records within date range
- LINQ: How to check for zero-divider within type?
- Get data in a specific date for a time range with a minute difference
- Check Nullable for object insde LinQ to Sql code
- Linq query within a date range on several tables?
- Sort the List by Date for Next 30 days and Display in List Box in C#
- Calculate exact no of week for date range
- Linq query for Get Data within Date in .net core
- Check if two dates completely overlaps a date range
More Query from same tag
- get a List of Max values across a list of lists
- Nullable Parameter used in Lambda Query is being ignored
- How to select Distinct / Group By child property in both LINQ method and syntax?
- Update one DataTable from another
- Null check for reflected property's value with Any() keyword
- Linq: Count value of multiple column
- System.Linq.Select method error: LINQ to Entities does not recognize the method
- Passing joined table to view as model Asp.Net Core
- linq list string like
- how to select multiple columns without anonymously return the result in linq?
- how to get sum of columns in nhibernate linq
- Is Microsoft going to support SQL Server 2008 with LINQ in Visual Studio 2010?
- Select multiple columns from Linq query
- How to improve Query with linq
- Get all column names of a DataTable into string array using (LINQ/Predicate)
- Create Custom List using Lambda Expression
- The correct way to calculate the length of a numeric string
- Check a list of DTOs using linq to see if all values that exclude a particular value all equal the same thing
- Linq, EF Core - group by on one field and use other field to get list of data from other table
- How to refresh a C# DataTable with updated data due to adding to table with autoincrement?
- Populate an object with an ObservableCollection property using Linq
- How to Generate Combinations of Elements of a List<T> in .NET 4.0
- Take groups of 5 strings from List
- c# conditional OrderBy
- populating object collection property with Linq
- Find from a hashtable using the value
- How to Write LINQ with multiple condition
- How to make LINQ execute a (SQL) LIKE range search
- Query a byte property with nhibernate cause invalid cast error
- Dynamic Pivot Linq C#