sqlkata/querybuilder

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

lilacse opened this issue · 1 comments

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.

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.