Support for IQueryable<TEntity> as data source for UpsertRange<TEntity>?
See original GitHub issueI am faced with a scenario where it would be super desireable to be able to pass an IQueryable<TEntity>
to UpsertRange<TEntity>
instead of an IEnumerable<TEntity>
or TEntity[]
.
This should then result in the UPSERT being run entirely on the DB side as opposed to loading entities into memory. I.e.:
var someSourceEntitiesProjectionToDailyVisits = dataContext.SomeSourceEntities
.Where(x => x.SomeSourceEntityProperty == someValue)
.Select(x => new {
UserID = x.SomeFieldMatchedToUserId,
Date = DateTime.UtcNow.Date
});
dataContext.DailyVisits
.UpsertRange(someSourceEntitiesProjectionToDailyVisits)
.On(v => new { v.UserID, v.Date })
.WhenMatched(v => new DailyVisit
{
Visits = v.Visits + 1,
})
.RunAsync();
Is something like this on the roadmap?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How can I return IQueryable<TEntity> object from a mock ...
Unless your business logic actually creates an implementation of IQueryable<T> then you want to return a mock stub object.
Read more >IQueryable Interface (System.Linq)
Provides functionality to evaluate queries against a specific data source wherein the type of the data is not specified.
Read more >Supported and Unsupported LINQ Methods (LINQ to Entities)
This article summarizes the standard query operators that are supported and unsupported in LINQ to Entities queries.
Read more >IEnumerable VS IQueryable
IEnumerable doesn't support custom query. ... queries over local collection objects and remote data sources like SQL, XML documents, etc.
Read more >The Difference Between IEnumerable and IQueryable Explained
The Users class is a stand in for the Users database table. The Users data doesn't exist in our app. In order to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, this totally makes sense to me now. It is similar to the INSERT INTO … SELECT … ON DUPLICATE KEY UPDATE pattern that I grew to love in MySQL. I am not sure what it will take to implement something like this so I’ll let @artiomchi take it from here. Sorry I could not be more helpful 😦
Going to close this issue due to inactivity. Also, as explained above - this is too much outside the scope of this project