private void btnCreate_Click(object sender, EventArgs e) { SqlConfig config = new SqlConfig(DataDriverType.Sqlite, this.txtDataPre.Text, "", this.txtDBPath.Text); DataOperator dop = new DataOperator(config); Compile.CSharpCodeCompiler compiler = new Compile.CSharpCodeCompiler(); foreach(var item in this.lbxModels.Items) { try { var assembly = compiler.Compile(File.ReadAllText(item.ToString())); foreach (var type in assembly.GetTypes()) { dop.CreateTable(type); } MessageBox.Show("操作成功!"); } catch(Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// Initialize a new instance of the SqlXmlLoader. /// </summary> /// <param name="config">The config instance.</param> public SqlXmlLoader(SqlConfig config) { if (config == null) throw new ArgumentNullException("config"); Config = config; }
private void context_BeginRequest(object sender, EventArgs e) { HttpApplication application = (HttpApplication)sender; HttpContext httpContext = application.Context; SqlConfig config = new SqlConfig(IOHelper.ConvertToFullPath(GlobalConfig.Get().Database)); httpContext.Items.Add("config", config); httpContext.Items.Add("context", config.CreateContext()); }
public int ImportSql(string sqlFile, SqlConfig sqlCfg) { return 0; }
public void Connect(SqlConfig sqlConfig) { _sqlConfig = sqlConfig; _connection = new NpgsqlConnection(sqlConfig.ToConnectionString()); }
public AccountRep(IOptions <SqlConfig> configOptions) { config = configOptions.Value; }
public PSQLStorageContainer(IOptions <SqlConfig> configOptions) { config = configOptions.Value; }
public TReturn GetBuilder <TReturn>(ProxyData proxyData, SqlConfig setting, JObject rawData) where TReturn : class { this.Data = new StrategyData <JObject>(proxyData, setting, rawData); return(this.Parse(setting) as TReturn); }
public static void DeleteChildrenBySetting(IDbContext db, SqlConfig setting, List <DbField> dependencyFields) { StringBuilder sqlSb = new StringBuilder(); sqlSb.AppendFormat("Delete From {0} Where ", setting.Table); int idx = 0; var para = new List <DbField>(); dependencyFields.ForEach(f => { if (idx == 0) { sqlSb.AppendFormat(" {0} = @__P{1}", f.DbName, ++idx); } else { sqlSb.AppendFormat(" And {0} = @__P{1}", f.DbName, ++idx); } para.Add(new DbField { ParamName = "__p" + idx, Value = f.DependencyField.Value }); }); //delete it's children if (setting.Children.Any()) { setting.Children.ForEach(cSetting => { //iterate it to get the dependency data StringBuilder sqlQuerySb = new StringBuilder(); sqlQuerySb.AppendFormat("Select * From {0} Where ", setting.Table); int cIdx = 0; var cPara = new List <DbField>(); dependencyFields.ForEach(f => { if (cIdx == 0) { sqlQuerySb.AppendFormat(" {0} = @__P{1}", f.DbName, ++cIdx); } else { sqlQuerySb.AppendFormat(" And {0} = @__P{1}", f.DbName, ++cIdx); } cPara.Add(new DbField { ParamName = "__p" + cIdx, Value = f.DependencyField.Value }); }); var builderQuery = db.Sql(sqlQuerySb.ToString()); cPara.ForEach(x => { builderQuery.Parameter(x.ParamName, x.Value); }); // delete it's children var table = builderQuery.QuerySingle <DataTable>(); if (table.Rows.Count > 0 && cSetting.Dependency.Fields.Any()) { table.Rows.Cast <DataRow>().ToList().ForEach(r => { var cDependencyFields = new List <DbField>(); cSetting.Dependency.Fields.ForEach(df => { cDependencyFields.Add(new DbField { DbName = df.DbName, DependencyField = new DbField { DbName = df.DependencyName, Value = r[df.DependencyName] } }); }); // delete children DeleteChildrenBySetting(db, cSetting, cDependencyFields); }); } //DeleteChildrenBySetting(cSetting); }); } var builder = db.Sql(sqlSb.ToString()); para.ForEach(p => { builder.Parameter(p.ParamName, p.Value); }); builder.Execute(); }
public List <IDbBuilder> ToDbBuilder(SqlConfig setting) { return(this.Proxy.ToDbBuilders <JObject>(setting, this.RawData as JObject)); }
public ISelectBuilder ToSelectBuilder(SqlConfig setting, OperateType ot = OperateType.MutipleSelect) { return(this.Proxy.ToSelectBuilder <T>(setting, this.RawData, ot)); }
public SqlContextData(SqlConfig context) { _context = context; CreateDataBase(); }
public FilmService(SqlConfig config) { _configuration = config; _filmRepository = new FilmRepository(config.ConnectionString); }
public void ImportSql(string sqlFile, SqlConfig sqlCfg) { _SqlEngine.ImportSql(sqlFile, sqlCfg); }