public void AddModel(ECommonModel model) { model.CommonModelTableName = model.CommonModelTableName.ToLower(); if (_rep.Get<ECommonModel>(p => p.CommonModelTableName == model.CommonModelTableName) != null) { throw new Exception(string.Format("已经存在表cms_contents_{0}", model.CommonModelTableName)); } if (_rep.Add(model) > 0) { //添加默认Part TextPart part = new TextPart(); part.CommonModelId = model.Id; part.PartLeft = 30; part.PartTop = 20; part.PartWidth = 10; part.SettingName = "Title"; part.SettingLabelName = "标题"; part.SettingTip = "标题"; part.SettingFieldLength = 100; part.SettingLabelWidth = 2; part.SettingContentWidth = 5; part.AddDefaultCommonModelPart(); //添加物理表 SchemaBuilder .UseConnection(_rep.ConnectionString) .CreateTable("cms_contents_" + model.CommonModelTableName, t => { t.Column("ItemId", DbType.Int32, c => c.Identity().PrimaryKey()); }); } }
public void SaveModel(ECommonModel model) { _rep.Save(model, p => p.Id == model.Id); }