本文整理汇总了C#中OrmLiteConnectionFactory.SaveAll方法的典型用法代码示例。如果您正苦于以下问题:C# OrmLiteConnectionFactory.SaveAll方法的具体用法?C# OrmLiteConnectionFactory.SaveAll怎么用?C# OrmLiteConnectionFactory.SaveAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrmLiteConnectionFactory
的用法示例。
在下文中一共展示了OrmLiteConnectionFactory.SaveAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_SaveAll_and_select_from_ModelWithFieldsOfDifferentTypes_table_with_no_ids
public void Can_SaveAll_and_select_from_ModelWithFieldsOfDifferentTypes_table_with_no_ids()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithFieldsOfDifferentTypes>(true);
db.DeleteAll<ModelWithFieldsOfDifferentTypes>();
var rowIds = new List<int> {1, 2, 3, 4, 5};
var newRows = rowIds.ConvertAll(x => ModelWithFieldsOfDifferentTypes.Create(default(int)));
db.SaveAll(newRows);
var rows = db.Select<ModelWithFieldsOfDifferentTypes>();
Assert.That(rows, Has.Count.EqualTo(newRows.Count));
}
}
示例2: Can_SaveAll_and_select_from_Movie_table
public void Can_SaveAll_and_select_from_Movie_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<Movie>(true);
var top5Movies = new List<Movie>
{
new Movie
{
Id = "tt0111161",
Title = "The Shawshank Redemption",
Rating = 9.2m,
Director = "Frank Darabont",
ReleaseDate = new DateTime(1995, 2, 17),
TagLine = "Fear can hold you prisoner. Hope can set you free.",
Genres = new List<string> {"Crime", "Drama"},
},
new Movie
{
Id = "tt0068646",
Title = "The Godfather",
Rating = 9.2m,
Director = "Francis Ford Coppola",
ReleaseDate = new DateTime(1972, 3, 24),
TagLine = "An offer you can't refuse.",
Genres = new List<string> {"Crime", "Drama", "Thriller"},
},
new Movie
{
Id = "tt1375666",
Title = "Inception",
Rating = 9.2m,
Director = "Christopher Nolan",
ReleaseDate = new DateTime(2010, 7, 16),
TagLine = "Your mind is the scene of the crime",
Genres = new List<string> {"Action", "Mystery", "Sci-Fi", "Thriller"},
},
new Movie
{
Id = "tt0071562",
Title = "The Godfather: Part II",
Rating = 9.0m,
Director = "Francis Ford Coppola",
ReleaseDate = new DateTime(1974, 12, 20),
Genres = new List<string> {"Crime", "Drama", "Thriller"},
},
new Movie
{
Id = "tt0060196",
Title = "The Good, the Bad and the Ugly",
Rating = 9.0m,
Director = "Sergio Leone",
ReleaseDate = new DateTime(1967, 12, 29),
TagLine = "They formed an alliance of hate to steal a fortune in dead man's gold",
Genres = new List<string> {"Adventure", "Western"},
},
};
db.SaveAll(top5Movies);
var rows = db.Select<Movie>();
Assert.That(rows, Has.Count.EqualTo(top5Movies.Count));
}
}