public static void Setup(int testItems) { SetTestRepo(); for (int i = 0; i < testItems; i++) { Taxa item = new Taxa(); _testRepo._items.Add(item); } }
public override bool Equals(object obj) { if (obj.GetType() == typeof(Taxa)) { Taxa compare = (Taxa)obj; return(compare.KeyValue() == this.KeyValue()); } else { return(base.Equals(obj)); } }
public static Taxa SingleOrDefault(Expression <Func <Taxa, bool> > expression, string connectionString, string providerName) { var repo = GetRepo(connectionString, providerName); var results = repo.Find(expression); Taxa single = null; if (results.Count() > 0) { single = results.ToList()[0]; } return(single); }
public static Taxa SingleOrDefault(Expression <Func <Taxa, bool> > expression) { var repo = GetRepo(); var results = repo.Find(expression); Taxa single = null; if (results.Count() > 0) { single = results.ToList()[0]; single.OnLoaded(); single.SetIsLoaded(true); single.SetIsNew(false); } return(single); }
void Init() { TestMode = this._db.DataProvider.ConnectionString.Equals("test", StringComparison.InvariantCultureIgnoreCase); _dirtyColumns = new List <IColumn>(); if (TestMode) { Taxa.SetTestRepo(); _repo = _testRepo; } else { _repo = new SubSonicRepository <Taxa>(_db); } tbl = _repo.GetTable(); SetIsNew(true); OnCreated(); }
internal static IRepository <Taxa> GetRepo(string connectionString, string providerName) { SpeciesSolution.DataAccess.DataModel.SpeciesDB db; if (String.IsNullOrEmpty(connectionString)) { db = new SpeciesSolution.DataAccess.DataModel.SpeciesDB(); } else { db = new SpeciesSolution.DataAccess.DataModel.SpeciesDB(connectionString, providerName); } IRepository <Taxa> _repo; if (db.TestMode) { Taxa.SetTestRepo(); _repo = _testRepo; } else { _repo = new SubSonicRepository <Taxa>(db); } return(_repo); }
public static void Setup(Taxa item) { SetTestRepo(); _testRepo._items.Add(item); }
public static void Setup(int testItems) { SetTestRepo(); for(int i=0;i<testItems;i++){ Taxa item=new Taxa(); _testRepo._items.Add(item); } }
/// <summary> /// 将Taxa记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.Taxa) /// </summary> /// <param name="model">SubSonic插件生成的实体</param> /// <returns>DataAccess.Model.Taxa</returns> public DataAccess.Model.Taxa Transform(Taxa model) { if (model == null) return null; return new DataAccess.Model.Taxa { Id = model.Id, Rank_Id = model.Rank_Id, Parent_Id = model.Parent_Id, TaxaCName = model.TaxaCName, TaxaLName = model.TaxaLName, RefArticles = model.RefArticles, TaxaPic = model.TaxaPic, }; }
/// <summary> /// 更新IIS缓存中指定Id记录 /// </summary> /// <param name="model">记录实体</param> public void SetModelForCache(Taxa model) { SetModelForCache(Transform(model)); }
/// <summary> /// 添加与编辑Taxa记录 /// </summary> /// <param name="page">当前页面指针</param> /// <param name="model">Taxa表实体</param> /// <param name="content">更新说明</param> /// <param name="isCache">是否更新缓存</param> /// <param name="isAddUseLog">是否添加用户操作日志</param> public void Save(Page page, Taxa model, string content = null, bool isCache = true, bool isAddUseLog = true) { try { //保存 model.Save(); //判断是否启用缓存 if (CommonBll.IsUseCache() && isCache) { SetModelForCache(model); } if (isAddUseLog) { if (string.IsNullOrEmpty(content)) { content = "{0}" + (model.Id == 0 ? "添加" : "编辑") + "Taxa记录成功,ID为【" + model.Id + "】"; } //添加用户访问记录 CommonBll.WriteLog(content); //UseLogBll.GetInstence().Save(page, content); } } catch (Exception e) { var result = "执行TaxaBll.Save()函数出错!"; //出现异常,保存出错日志信息 CommonBll.WriteLog(result, e); } }