TortugaResearch / Tortuga.Chain

A fluent ORM for .NET
Other
336 stars 22 forks source link

Generic InsertBatch Method aka Class #381

Closed uwerichter closed 3 years ago

uwerichter commented 4 years ago

We would like to do something like:

` public class Repository : DBDataSource { public Task Write(string tableName, List data, string dbschemaName = "dbo") where T : class, new() { var ss = new Tortuga.Chain.SqlServer.SqlServerObjectName("dbo", tableName); return DB.InsertBatch(dbschemaName + "." + tableName, data.AsReadOnly()).ToObject().ExecuteAsync();

... } } new Repository().Write("ClassName", talkCNCPoint.MeasurementPoints);

The Ideas is some Generic Repository Class.

Grauenwolf commented 3 years ago

I don't really understand this request.

If you have a collection of objects talkCNCPoint.MeasurementPoints then you can just write...

DB.InsertBatch(tableName, talkCNCPoint.MeasurementPoints).ExecuteAsync();

It will infer the schema name from the table name. You don't have to use a SqlServerObjectName directly.