public void SaveTableInfo_Test() { var ci = GetContainer(); var uow = ci.Resolve <IUnitOfWork>(); ITableInfoRepository rep = ci.Resolve <ITableInfoRepository>(); var tabInfo = new TableInfo("customer", "客户表"); tabInfo.AddColumnInfo("id", Common.DataManage.FormItemType.Number, "id", true, true); tabInfo.AddColumnInfo("code", Common.DataManage.FormItemType.Text, "客户编号", false, false); tabInfo.AddColumnInfo("name", Common.DataManage.FormItemType.Text, "客户名称", false, false); tabInfo.AddColumnInfo("company", Common.DataManage.FormItemType.Text, "客户公司", false, false); tabInfo.AddColumnInfo("sex", Common.DataManage.FormItemType.RadioButtonList, "客户性别", false, false); rep.Add(tabInfo); uow.Commit(); }
private void AddTable() { bool tableExist = _tableInfoRepository.Exists(t => t.Name == Request.Name); if (tableExist) { throw new MyFX.Core.Exceptions.AppServiceException(string.Format("名为[{0}]的表已存在", Request.Name)); } var tabInfo = new TableInfo(Request.Name, Request.Desc); foreach (var item in Request.ColumnInfos) { tabInfo.AddColumnInfo(item.Name, item.FormItemType, item.Desc, item.IsPrimaryKey, item.IsSystem, item.Sort); } _tableInfoRepository.Add(tabInfo); _uow.Commit(); string createTableSql = GetCreateTableSql(tabInfo); SqlHelper.ExecuteNonQuery(createTableSql); }