Sort list with Simple.Data

Attempt to do:

var list = new List<MyType>(); list.Add(new MyType() { PK1 = 1, PK2 = 2 }); list.Add(new MyType() { PK1 = 1, PK2 = 3 }); Database.Open().MySchema.MyTable.Upsert(list); 

Nothing seems to be happening, do I need to do foreach or can I do it somehow?

+4
source share
2 answers

This will work or any other enumeration of the result.

Database.Open().MySchema.MyTable.Upsert(list).ToArray();

Although it will not generate a batch SQL query, there will be many queries in the database, at least for SQL Server.

+5
source

Whether there is a

 Database.Open().MySchema.MyTable.Upsert( new MyType { PK1 = 1, PK2 = 2 } ); 

Job?

ToArray () -

 var list = new List<MyType>(); list.Add(new MyType() { PK1 = 1, PK2 = 2 }); list.Add(new MyType() { PK1 = 1, PK2 = 3 }); Database.Open().MySchema.MyTable.Upsert(list.ToArray()); 
+1
source

Source: https://habr.com/ru/post/1486834/


All Articles