-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IEnumerable<TEntity> support #15
Conversation
Oooh, that's a great idea! I don't know why I haven't thought of adding an Sorry for taking the liberty to make changes - I have a bit of an OCD with formatting and extra line breaks and the like :) Also, I noticed you changed the methods to use I think it would make a lot more sense to use Another reason I think this approach is superior is ensures there will be no issues with lazy loaded sets, since we either ensure that the collection is already loaded into memory before it's passed to us, or we convert it to an array to do that. Regarding backwards compatibility, all these changes are done in mostly new classes that haven't been released yet, so there are no issues there. And we're just adding new extension methods, so there should be no problems there either. What do you think? Do you have anything to add to this before it's merged? |
Oh, thank you for your notice! I think |
Regarding UpdateColumns - yeah.. I was thinking of adding that as an override, but haven't implemented it yet. Not enough hours in the day :) I'm not very happy with the method names either.. I'm considering renaming them before the release.. maybe from Or better yet: |
Oh, right, INSERT INTO table_name(column_list) VALUES(value_list)
ON CONFLICT target action; I want to write: dbContext.Items.UpsertRange(newItems)
.OnConflict(x => x.IdentitcalField)
.DoUpdate((matched, newItem) => new Item()
{
Field = newItem.Field
});
dbContext.Items.UpsertRange(newItems)
.OnConflict(x => x.IdentitcalField)
.DoNothing(); What about let the |
Umm. Actually, yeah.. that sounds better.. although I'm not too keen on the word Conflict.. Regarding
|
I agree with you about that two points. But it's semetically better to duplicate the update calls, like this: dbContext.Items.UpsertRange(newItems)
.OnConflict(x => x.IdentitcalField)
.DoUpdate((matched, newItem) => new Item()
{
Field = newItem.Field,
Visit = matched.Visit + 1
});
dbContext.Items.UpsertRange(newItems)
.OnConflict(x => x.IdentitcalField)
.DoUpdateAsync((matched, newItem) => new Item()
{
Field = newItem.Field,
Visit = matched.Visit + 1
});
dbContext.Items.UpsertRange(newItems)
.OnConflict(x => x.IdentitcalField)
.DoUpdate();
dbContext.Items.UpsertRange(newItems)
.OnConflict(x => x.IdentitcalField)
.DoUpdateAsync();
dbContext.Items.UpsertRange(newItems)
.OnConflict(x => x.IdentitcalField)
.DoNothing();
dbContext.Items.UpsertRange(newItems)
.OnConflict(x => x.IdentitcalField)
.DoNothingAsync();
// Infer the match fields to detected primary keys or alternative keys
dbContext.Items.UpsertRange(newItems);
dbContext.Items.UpsertRangeAsync(newItems); Of course, this would increase our work. What do you think about? |
Yeah, I was thinking the same (about moving this to a new issue) :) |
Since UpsertRange now just support TEntity[]. I'm trying to add overloads which consumes IEnumerable, but discussions are needed since this may broken old APIs.