本文整理汇总了C#中IDbConnection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.Insert方法的具体用法?C# IDbConnection.Insert怎么用?C# IDbConnection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbConnection
的用法示例。
在下文中一共展示了IDbConnection.Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateGalleryTypeTable
private void PopulateGalleryTypeTable(IDbConnection conn)
{
conn.Insert(new GalleryType { GalleryTypeId = 1, GalleryTypeName = "Root" });
conn.Insert(new GalleryType { GalleryTypeId = 2, GalleryTypeName = "Trash" });
conn.Insert(new GalleryType { GalleryTypeId = 3, GalleryTypeName = "Preview" });
conn.Insert(new GalleryType { GalleryTypeId = 4, GalleryTypeName = "Content" });
}
示例2: Init
public void Init(IDbConnection db)
{
db.DropAndCreateTable<Person>();
db.DropAndCreateTable<Band>();
db.InsertAll(Person.Rockstars);
db.Insert(new Band { Name = "The Doors", PersonId = 3 });
db.Insert(new Band { Name = "Nirvana", PersonId = 4 });
}
示例3: Init
private static void Init(IDbConnection db)
{
db.DropAndCreateTable<ClassA>();
db.DropAndCreateTable<ClassB>();
_classAColumnAId = db.Insert(new ClassA { ColumnA = "1" }, true);
db.Insert(new ClassA { ColumnA = "2" });
db.Insert(new ClassA { ColumnA = "3" });
db.Insert(new ClassB { ColumnB = "1" });
db.Insert(new ClassB { ColumnB = "2" });
}
示例4: InitLetters
private static void InitLetters(IDbConnection db)
{
db.DropAndCreateTable<LetterFrequency>();
db.Insert(new LetterFrequency { Letter = "A" });
db.Insert(new LetterFrequency { Letter = "B" });
db.Insert(new LetterFrequency { Letter = "B" });
db.Insert(new LetterFrequency { Letter = "C" });
db.Insert(new LetterFrequency { Letter = "C" });
db.Insert(new LetterFrequency { Letter = "C" });
db.Insert(new LetterFrequency { Letter = "D" });
db.Insert(new LetterFrequency { Letter = "D" });
db.Insert(new LetterFrequency { Letter = "D" });
db.Insert(new LetterFrequency { Letter = "D" });
}
示例5: Manager
public Manager(IDbConnection dbConnection, string rootFolder)
{
if (dbConnection == null) throw new ArgumentNullException("dbConnection");
if (rootFolder == null) throw new ArgumentNullException("rootFolder");
if (dbConnection.State != ConnectionState.Open) throw new ArgumentException("dbConnection must be in an open state.");
db = dbConnection;
this.rootFolder = rootFolder;
if (!IO.Directory.Exists(rootFolder))
IO.Directory.CreateDirectory(rootFolder);
//Validate the root folder exists
Folder root = GetFolder("/");
if (root == null)
{
root = new Folder()
{
CreatedTimeStamp = DateTime.UtcNow,
FullPath = "/",
Name = "",
IsDeleted = false,
IsPurged = false,
LastModifiedTimestamp = DateTime.UtcNow,
ParentFolderId = null
};
db.Insert<Folder>(root);
}
}
示例6: InitLetters
public static int InitLetters(IDbConnection db)
{
db.DropAndCreateTable<LetterFrequency>();
var firstId = db.Insert(new LetterFrequency { Letter = "A" }, selectIdentity: true);
db.Insert(new LetterFrequency { Letter = "B" });
db.Insert(new LetterFrequency { Letter = "B" });
db.Insert(new LetterFrequency { Letter = "C" });
db.Insert(new LetterFrequency { Letter = "C" });
db.Insert(new LetterFrequency { Letter = "C" });
db.Insert(new LetterFrequency { Letter = "D" });
db.Insert(new LetterFrequency { Letter = "D" });
db.Insert(new LetterFrequency { Letter = "D" });
db.Insert(new LetterFrequency { Letter = "D" });
return (int)firstId;
}
示例7: CreateAndInitialize
private DefaultValues CreateAndInitialize(IDbConnection db, int count = 1)
{
db.DropAndCreateTable<DefaultValues>();
db.GetLastSql().Print();
DefaultValues firstRow = null;
for (var i = 1; i <= count; i++)
{
var defaultValues = new DefaultValues { Id = i };
db.Insert(defaultValues);
var row = db.SingleById<DefaultValues>(1);
row.PrintDump();
Assert.That(row.DefaultInt, Is.EqualTo(1));
Assert.That(row.DefaultIntNoDefault, Is.EqualTo(0));
Assert.That(row.NDefaultInt, Is.EqualTo(1));
Assert.That(row.DefaultDouble, Is.EqualTo(1.1).Within(.1d));
Assert.That(row.NDefaultDouble, Is.EqualTo(1.1).Within(.1d));
Assert.That(row.DefaultString, Is.EqualTo("String"));
if (firstRow == null)
firstRow = row;
}
return firstRow;
}
示例8: InsertAndSelectDateTime
private static DateTimeObject InsertAndSelectDateTime(IDbConnection db, DateTime dateTime)
{
db.DropAndCreateTable<DateTimeObject>();
db.Insert(new DateTimeObject {Test = dateTime});
var x = db.Select<DateTimeObject>().First();
return x;
}
示例9: InsertData
private void InsertData(IDbConnection db, int count)
{
for (var i = 0; i < count; i++)
{
var data = new CompositeKey {SubId1 = SubId1Value, SubId2 = SubId2Value, Data = Guid.NewGuid().ToString()};
db.Insert(data);
}
}
示例10: InsertBoard
private static long InsertBoard(IDbConnection cnn)
{
return cnn.Insert(new Board()
{
Name = "Sample board",
});
}
示例11: Run
protected override void Run(IDbConnection db)
{
if (this.IsFirstRun)
{
db.CreateTable<Supplier>(true);
}
db.Insert(NorthwindFactory.Supplier(this.Iteration, "Exotic Liquids", "Charlotte Cooper", "Purchasing Manager", "49 Gilbert St.", "London", null, "EC1 4SD", "UK", "(171) 555-2222", null, null));
}
示例12: Run
protected override void Run(IDbConnection db)
{
if (this.IsFirstRun)
{
db.CreateTable<ModelWithFieldsOfDifferentTypesPerf>(true);
}
db.Insert(ModelWithFieldsOfDifferentTypesPerf.Create(this.Iteration));
}
开发者ID:CormacBrennan-AI,项目名称:ServiceStack.OrmLite,代码行数:9,代码来源:InsertModelWithFieldsOfDifferentTypesScenario.cs
示例13: InsertModelWithComplexType
private static void InsertModelWithComplexType(IDbConnection db)
{
db.DropAndCreateTable<ModelWithComplexType>();
db.Insert(new ModelWithComplexType {
Id = 1,
ComplexType = new ComplexType { Id = 2, SubType = new SubType { Name = "Sub" } }
});
}
示例14: Run
protected override void Run(IDbConnection db)
{
if (this.IsFirstRun)
{
db.CreateTable<SampleOrderLine>(true);
}
db.Insert(SampleOrderLine.Create(userId, this.Iteration, 1));
}
示例15: DoInsertUpdate
private static void DoInsertUpdate(IDbConnection db)
{
db.CreateTable<ParamPassword>(true);
var row = new ParamPassword { Id = 2, Password = 6 };
db.Insert(row);
row.Password = 335;
db.Update(row);
}