/// <summary> /// 如果用DbMigration自带的CreateTable方法,会造成死循环。 /// </summary> /// <typeparam name="TColumns"></typeparam> /// <param name="d"></param> /// <param name="name"></param> /// <param name="columnsAction"></param> /// <param name="annotations"></param> /// <param name="anonymousArguments"></param> /// <returns></returns> private static TableBuilder <TColumns> CreateTableWithComment <TColumns>(this DbMigration d, string name, Func <ColumnBuilder, TColumns> columnsAction, IDictionary <string, object> annotations, object anonymousArguments = null) { if (string.IsNullOrEmpty(name)) { throw new Exception("创建表时必须设置表名。"); } if (columnsAction == null) { throw new Exception("创建表时必须设置列对象。"); } CreateTableOperation createTableOperation = new CreateTableOperation(name, annotations, anonymousArguments); (d as IDbMigration).AddOperation(createTableOperation); //添加列 TColumns columns = columnsAction(new ColumnBuilder()); columns.GetType().GetNonIndexerProperties().ForEach(p => { ColumnModel columnModel = p.GetValue(columns, null) as ColumnModel; if (columnModel != null) { //columnModel..ApiPropertyInfo = p; columnModel.GetType().GetField("_apiPropertyInfo", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(columnModel, p); if (string.IsNullOrWhiteSpace(columnModel.Name)) { columnModel.Name = p.Name; } createTableOperation.Columns.Add(columnModel); } }); return(new TableBuilder <TColumns>(createTableOperation, d)); }
public void Add() { for (int i = 1; i <= 400000; i++) { ColumnModel MianModel = new ColumnModel(); foreach (var p in MianModel.GetType().GetProperties().ToList()) { //µç»° if (p.Name == "Column30") { List <T2_ModifyJsonModel> lst = new List <T2_ModifyJsonModel>(); for (int j = 1; j <= 4; j++) { T2_ModifyJsonModel tel = new T2_ModifyJsonModel(); foreach (var t in tel.GetType().GetProperties().ToList()) { t.SetValue(tel, t.Name.ToString() + "-" + j.ToString()); } lst.Add(tel); } p.SetValue(MianModel, lst); } else if (p.Name == "Column4" || p.Name == "Column5" || p.Name == "Column6" || p.Name == "Column7" || p.Name == "Column8" ) { List <T2_ModifyLogModel> lst = new List <T2_ModifyLogModel>(); for (int j = 1; j <= 15; j++) { T2_ModifyLogModel mod = new T2_ModifyLogModel(); foreach (var t in mod.GetType().GetProperties().ToList()) { t.SetValue(mod, t.Name.ToString() + "-" + j.ToString()); } lst.Add(mod); } p.SetValue(MianModel, lst); } else { p.SetValue(MianModel, p.Name.ToString() + "-" + i.ToString()); } } t2_house house = new t2_house(); house.id = i; house.jsonstr = JsonHelper.Instance.Serialize(MianModel); house.Insert(); } }
//public virtual IGnosisGridFieldImplementation GetFieldClone() //{ // IGnosisGridFieldImplementation gridFieldImp = fieldController.GetClone(); // gridFieldImp.Order = columnModel.Order; // fields.Add(gridFieldImp); // return gridFieldImp; //} public virtual IGnosisGridFieldImplementation GetFieldClone() { IGnosisGridFieldImplementation gridField = null; if (ColumnModel is GnosisTextColumn) { gridField = GnosisControlCreator.CreateGnosisGridTextField((GnosisTextColumn)ColumnModel); } else if (ColumnModel is GnosisCheckColumn) { gridField = GnosisControlCreator.CreateGnosisGridCheckField((GnosisCheckColumn)ColumnModel); } else if (ColumnModel is GnosisDateColumn) { gridField = GnosisControlCreator.CreateGnosisGridDateField((GnosisDateColumn)ColumnModel); } else if (ColumnModel is GnosisDateTimeColumn) { gridField = GnosisControlCreator.CreateGnosisGridDateTimeField((GnosisDateTimeColumn)ColumnModel); } else if (ColumnModel is GnosisComboColumn) { gridField = GnosisControlCreator.CreateGnosisGridComboField((GnosisComboColumn)ColumnModel); } else if (ColumnModel is GnosisLinkColumn) { gridField = GnosisControlCreator.CreateGnosisGridLinkField((GnosisLinkColumn)ColumnModel); } else if (ColumnModel is GnosisNumberColumn) { gridField = GnosisControlCreator.CreateGnosisGridNumberField((GnosisNumberColumn)ColumnModel); } else if (ColumnModel is GnosisTextResults) { gridField = GnosisControlCreator.CreateGnosisResultsTextField((GnosisTextResults)ColumnModel); } else if (ColumnModel is GnosisCheckResults) { gridField = GnosisControlCreator.CreateGnosisResultsCheckField((GnosisCheckResults)ColumnModel); } else if (ColumnModel is GnosisDateResults) { gridField = GnosisControlCreator.CreateGnosisResultsDateField((GnosisDateResults)ColumnModel); } else if (ColumnModel is GnosisDateTimeResults) { gridField = GnosisControlCreator.CreateGnosisResultsDateTimeField((GnosisDateTimeResults)ColumnModel); } else if (ColumnModel is GnosisNumberResults) { gridField = GnosisControlCreator.CreateGnosisResultsNumberField((GnosisNumberResults)ColumnModel); } if (gridField != null) { GlobalData.Singleton.StyleHelper.ApplyStyle(gridField, instanceController.EntityController.GetNormalStyle()); return(gridField); } else { GlobalData.Singleton.ErrorHandler.HandleError("Unknown column type: " + ColumnModel.GetType().ToString(), "GnosisGridColumnController.GetFieldClone"); return(null); } }