Skip to content
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

Supporting multi-row inserts with IEnumerable<IEnumerable<KeyValuePair<string, object>>> #663

Open
lilacse opened this issue Feb 22, 2023 · 1 comment

Comments

@lilacse
Copy link

lilacse commented Feb 22, 2023

Hi,

Since SqlKata supports creating insert queries from an IEnumerable<KeyValuePair<string, object>>, I think it would be great if we can also have an AsInsert() overload that takes an enumerable of that. List of dictionaries are quite common as a data structure as well, so I think this will be a useful addition.

I am interested in making a PR myself to implement that, but there's just one thing I'm not sure about - the most common implementation of IEnumerable<IEnumerable<KeyValuePair<string, object>>> might just be a list of dictionaries, and ordering of key-value pairs in dictionaries are not promised. Hence the code will need to reorder the entries, or iterate through the keys obtained from the first dictionary for every subsequent dictionary in the list to produce the correct output every time. Not very sure if this will be a concern (performance?) or which is the better approach in this case, so I hope to have some discussion on this before I start to try working on this :)

I also noticed that there was this PR #548 which seems to cover this (except for the ordering concern), but it's quite old and includes much more changes other than this.

lilacse added a commit to lilacse/querybuilder that referenced this issue Feb 26, 2023
@mkolumb
Copy link

mkolumb commented Mar 28, 2023

My PR #548 do more changes than one more overload, because with bigger queries unnecessary cast lead to poor performance.
StringBuilder is also important when building query.
I experienced this issue in my application.
This PR is up to date with master, but it looks @ahmad-moussawi doesn't have time to review.
I don't think ordering keys is good idea, this could have impact on performance and application which use builder should pass proper data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants