111,094
社区成员




ISession session = new Session(DBString);
//查询并且分页
Source s = session.Select(typeof(Source).Name).Skip(1, 1, Source.IDProty).ExecuteDataTable<Source>().First();
//删除
session.Delete(typeof(Source).Name).AddWhere(Source.IDProty, s.ID, WhereEnum.等于);
s.Title = "10000000000";
//修改
session.Update(typeof(Source).Name, s);
//添加
ISession sessions = new Session(DBString);
sessions.Insert(typeof(Source).Name, s);
ITransaction transactio = new Transaction();
//删除和添加操作放到了一起做事务
transactio.SetOperation(session);
transactio.SetOperation(sessions);
//事务
System.Console.WriteLine(transactio.Execute().ToString());
System.Console.WriteLine("Over");
System.Console.ReadLine();
public ISession AddWhere(string WhereValue){
this.Sql +=WhereValue;
}
调用的时候
session.Select(typeof(Source).Name).AddWhere("a = 1 or (b = 2 and c = 3)");
我想我写这样的方法才适合我的等级。。。。。。。。。。[/quote]
像hibernate的做法就是内部dsl,让用户以字符串的形式传入查询。那么你内部还需要转化成查询表达式。linq的好处就是,编译器帮你把解析的工作代劳了,你可以直接得到表达式树。public ISession AddWhere(string WhereValue){
this.Sql +=WhereValue;
}
调用的时候
session.Select(typeof(Source).Name).AddWhere("a = 1 or (b = 2 and c = 3)");
我想我写这样的方法才适合我的等级。。。。。。。。。。