BLToolKit: how to insert a list of objects?
-
28-09-2019 - |
Pergunta
Is it possible with BLToolKit (http://bltoolkit.net) to create a set of records for list of object (batch insert)?
If yes, how is this possible?
Thanks a lot!
Solução
using (var db = new DbManager())
db.InsertBatch(list);
Outras dicas
using (var db = new DbManager())
{
var ret = (from s in db.tablename
select new ObjectList
{
Id = (int)s.Id,
Name = s.Name
}).ToList();
return ret;
}
using (var db = new DbManager())
{
db.SetSpCommand("Person_Insert")
.ExecuteForEach<Person>(list);
}
Where list
is provided by other means of your application functionality.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow