public static void Execute(bool beginTransation, Action <IDataExecuteContext> action) { using (var ds = DataService.BeginSession(null, beginTransation)) { using (var helper = new DataExecuteContext(ds, beginTransation)) { action(helper); } } }
public static T Execute <T>(bool beginTransation, System.Func <IDataExecuteContext, T> func) { using (var ds = DataService.BeginSession(null, beginTransation)) { using (var helper = new DataExecuteContext(ds, beginTransation)) { return(func(helper)); } } }
public static void Execute <T>(bool beginTransation, System.Func <T, bool> func) where T : ISessionDataService { using (var ds = DataService.BeginSession(null, beginTransation)) { using (var helper = new DataExecuteContext(ds, beginTransation)) { var dt = helper.GetDataService <T>(); if (func(dt) && beginTransation) { helper.Commit(); } } } }
protected virtual void OnExecute(DataExecuteContext context, ExecutionStatement statement) { //根据生成的脚本创建对应的数据命令 var command = context.Session.Build(statement); if (context.IsScalar) { context.Result = command.ExecuteScalar(); return; } using (var reader = command.ExecuteReader()) { context.Result = this.Populate(reader, context.ResultType); } }