使用过ServiceStack.Ormlite的人都应该知道,其作为一个轻量级的ORM,使用的便捷度非常高,用起来就一个字:爽!而支撑其便捷度的,是库内大量地使用了扩展方法及静态变量. 首先先从源头入手分析(以下以Sqlite为例): OrmLiteConfig.DialectProvider = SqliteOrmLiteDialectProvider.Instance; using (IDbConnection db = "~/db.sqlite".MapAbsolutePath(…
复杂点的使用1 先看看这2个类 class Customer { public int Id { get; set; } ... } class CustomerAddress { public int Id { get; set; } public int CustomerId { get; set; } // Reference based on Property name convention } --- 也支持 别名 [Alias("LegacyCustomer")] clas…
ServiceStack.OrmLite 笔记1 ServiceStack.OrmLite 这个东东就是个orm框架,可以实现类似ef的效果.具体的就不这里班门弄斧了. 支持 SqlServerDialect.Provider // Any SQL Server Version SqlServer2012Dialect.Provider // SQL Server 2012+ SqliteDialect.Provider // Sqlite PostgreSqlDialect.Provider…
using ServiceStack; using ServiceStack.DataAnnotations; using ServiceStack.OrmLite; using ServiceStack.Text; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2.tes…
前文说到如果使用多数据库(不同SQL方言)时要如何开发?其实前文(第二篇)也有“透露”到.就是直接使用库提供的OrmLiteConnection 及OrmLiteConnectionFactory(IDbConnectionFactory) .我们先来看下代理类是怎么实现的: public class OrmLiteConnection : IDbConnection, IHasDbConnection, IHasDbTransaction { public readonly OrmLiteCo…
ps:写这篇文章的目的是尝试下新的markdown编辑器哈哈 简单介绍 ORMLite provides a lightweight Object Relational Mapping between Java classes and SQL databases. There are certainly more mature ORMs which provide this functionality including Hibernate and iBatis. However, the au…
group having 分页等 var ev = OrmLiteConfig.DialectProvider.SqlExpression(); group的使用 同sql一样,注意group分组的字段要在select里 ev.Select(c => new { c.Birthday, c.Active }).Where(rn => rn.Birthday >= new DateTime(year, 1, 1) && rn.Birthday <= lastDay).…
创建表 前一篇忘记写创建表了,这里补上.(其实前一篇也有那么一点) 建议安装源码里的t4模板看看效果先. public 的属性才有效 在表被创建或者删除的时候执行sql语句 [PostCreateTable("INSERT INTO TableWithSeedData (Name) VALUES ('Foo');" + "INSERT INTO TableWithSeedData (Name) VALUES ('Bar');")] public class Tabl…
公司原来用nhibernate,现在考虑要不要换一种ORM,于是找来了EF和ServiceStack.OrmLite.所以就产生了测试这三个性能的要求.对比三个ORM工具的性能,主要是对比ORM配置和启动速度:建表速度:插入行速度:修改行速度以及查询速度,删除用的比较少,就不测试了,还有发现EF貌似比nhibernate稍微快一些,就只测EF和ServiceStack.OrmLite了. 测试表结构 public class School { public Guid ID { get; set;…
目录[-] A Fast, Simple, Typed ORM for .NET Download 8 flavours of OrmLite is on NuGet: Docs and Downloads for older v3 BSD releases Copying Contributing Examples Querying with SELECT Convenient common usage data access patterns INSERT, UPDATE and DELET…