public static void Setup(int testItems)
 {
     SetTestRepo();
     for (int i = 0; i < testItems; i++)
     {
         RefTable item = new RefTable();
         _testRepo._items.Add(item);
     }
 }
 public override bool Equals(object obj)
 {
     if (obj.GetType() == typeof(RefTable))
     {
         RefTable compare = (RefTable)obj;
         return(compare.KeyValue() == this.KeyValue());
     }
     else
     {
         return(base.Equals(obj));
     }
 }
        public static RefTable SingleOrDefault(Expression <Func <RefTable, bool> > expression, string connectionString, string providerName)
        {
            var      repo    = GetRepo(connectionString, providerName);
            var      results = repo.Find(expression);
            RefTable single  = null;

            if (results.Count() > 0)
            {
                single = results.ToList()[0];
            }

            return(single);
        }
        public static RefTable SingleOrDefault(Expression <Func <RefTable, bool> > expression)
        {
            var      repo    = GetRepo();
            var      results = repo.Find(expression);
            RefTable 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)
     {
         RefTable.SetTestRepo();
         _repo = _testRepo;
     }
     else
     {
         _repo = new SubSonicRepository <RefTable>(_db);
     }
     tbl = _repo.GetTable();
     SetIsNew(true);
     OnCreated();
 }
        internal static IRepository <RefTable> 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 <RefTable> _repo;

            if (db.TestMode)
            {
                RefTable.SetTestRepo();
                _repo = _testRepo;
            }
            else
            {
                _repo = new SubSonicRepository <RefTable>(db);
            }
            return(_repo);
        }
 public static void Setup(RefTable item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Beispiel #8
0
 public static void Setup(int testItems)
 {
     SetTestRepo();
     for(int i=0;i<testItems;i++){
         RefTable item=new RefTable();
         _testRepo._items.Add(item);
     }
 }
Beispiel #9
0
 public static void Setup(RefTable item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
Beispiel #10
0
        /// <summary>
        /// 添加与编辑RefTable记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="model">RefTable表实体</param>
        /// <param name="content">更新说明</param>
        /// <param name="isCache">是否更新缓存</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Save(Page page, RefTable 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 ? "添加" : "编辑") + "RefTable记录成功,ID为【" + model.Id + "】";
                    }

                    //添加用户访问记录
                    CommonBll.WriteLog(content);
                    //UseLogBll.GetInstence().Save(page, content);
                }
            }
            catch (Exception e) {
                var result = "执行RefTableBll.Save()函数出错!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }
        }
Beispiel #11
0
        /// <summary>
        /// 将RefTable记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.RefTable)
        /// </summary>
        /// <param name="model">SubSonic插件生成的实体</param>
        /// <returns>DataAccess.Model.RefTable</returns>
        public DataAccess.Model.RefTable Transform(RefTable model)
        {
            if (model == null)
                return null;

            return new DataAccess.Model.RefTable
            {

                Taxa_Id = model.Taxa_Id,

                Article_Id = model.Article_Id,

            };
        }
Beispiel #12
0
 /// <summary>
 /// 更新IIS缓存中指定Id记录
 /// </summary>
 /// <param name="model">记录实体</param>
 public void SetModelForCache(RefTable model)
 {
     SetModelForCache(Transform(model));
 }