天道酬勤,学无止境

数据库查询

ServiceStack OrmLite 数据库查询 几个实用方法 (继承表格式化集合等)

执行SQL语句:int result = db.SqlScalar<int>("SELECT OBJECT_ID(@name)", new { name = "SomeName" });继承表的实现 (存储于同一个表中)[Alias("Table")] public abstract class MyBaseClass { public String Name { get; set; } public String Name1 { get; set; } public String Name2 { get; set; } } [Alias("Table")] public class MyDerivedClassA : MyBaseClass {} [Alias("Table")] public class MyDerivedClassB : MyBaseClass {}格式化查询: db.SelectFmt<Person>("Age > {0}", 40); Assert.That(db.GetLastSql(), Is.EqualTo("SELECT \"Id\", \"FirstName\", \"LastName\", \"Age\" FROM \"Person\" WHERE Age > 40")); db.SelectFmt<Person>("SELECT * FROM

2021-05-11 18:57:51    分类:博客    ServiceStack OrmLite    数据库查询   servicestack