本文整理汇总了C#中OrmLiteConnectionFactory.SelectFmt方法的典型用法代码示例。如果您正苦于以下问题:C# OrmLiteConnectionFactory.SelectFmt方法的具体用法?C# OrmLiteConnectionFactory.SelectFmt怎么用?C# OrmLiteConnectionFactory.SelectFmt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrmLiteConnectionFactory
的用法示例。
在下文中一共展示了OrmLiteConnectionFactory.SelectFmt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_query_using_float_in_alernate_culuture
public void Can_query_using_float_in_alernate_culuture()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<Point>(true);
db.Insert(new Point { Width = 4, Height = 1.123f, Top = 3.456d, Left = 2.345m});
var points = db.Select<Point>();
Console.WriteLine(points.Dump());
Assert.That(points[0].Width, Is.EqualTo(4));
Assert.That(points[0].Height, Is.EqualTo(1.123f));
Assert.That(points[0].Top, Is.EqualTo(3.456d));
Assert.That(points[0].Left, Is.EqualTo(2.345m));
points = db.SelectFmt<Point>("Height={0}", 1.123f); // returns no rows! FirebirdSql bug?
Assert.That(points.Count>0);
}
}
示例2: Can_select_with_filter_from_ModelWithOnlyStringFields_table
public void Can_select_with_filter_from_ModelWithOnlyStringFields_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithOnlyStringFields>(true);
var rowIds = new List<string>(new[] { "id-1", "id-2", "id-3" });
rowIds.ForEach(x => db.Insert(ModelWithOnlyStringFields.Create(x)));
var filterRow = ModelWithOnlyStringFields.Create("id-4");
filterRow.AlbumName = "FilteredName";
db.Insert(filterRow);
var rows = db.SelectFmt<ModelWithOnlyStringFields>("AlbumName = {0}", filterRow.AlbumName);
var dbRowIds = rows.ConvertAll(x => x.Id);
Assert.That(dbRowIds, Has.Count.EqualTo(1));
Assert.That(dbRowIds[0], Is.EqualTo(filterRow.Id));
}
}
示例3: Can_Select_In_for_string_value
public void Can_Select_In_for_string_value()
{
const int n = 5;
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithIdAndName>(true);
db.DeleteAll<ModelWithIdAndName>();
for(int i=1; i<=n; i++){
ModelWithIdAndName m = new ModelWithIdAndName(){
Name= "Name"+i.ToString()
};
db.Insert(m);
}
var selectInNames = new[] {"Name1", "Name2"};
var rows = db.SelectFmt<ModelWithIdAndName>("Name IN ({0})", selectInNames.SqlInValues());
Assert.That(rows.Count, Is.EqualTo(selectInNames.Length));
}
}
示例4: Can_populate_PocoFlagWithId
public void Can_populate_PocoFlagWithId()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
var rows = db.SelectFmt<PocoFlagWithId>("SELECT 1 as Id, 1 as Flag FROM RDB$DATABASE");
Assert.That(rows[0].Id, Is.EqualTo(1));
Assert.That(rows[0].Flag);
}
}
示例5: Can_Select_subset_ModelWithIdAndName_from_ModelWithFieldsOfDifferentTypes_table
public void Can_Select_subset_ModelWithIdAndName_from_ModelWithFieldsOfDifferentTypes_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithFieldsOfDifferentTypes>(true);
var rowIds = new List<int>(new[] { 1, 2, 3 });
rowIds.ForEach(x => db.Insert(ModelWithFieldsOfDifferentTypes.Create(x)));
var rows = db.SelectFmt<ModelWithIdAndName>("SELECT Id, Name FROM ModelWFDT");
var dbRowIds = rows.ConvertAll(x => x.Id);
Assert.That(dbRowIds, Is.EquivalentTo(rowIds));
}
}