Пример #1
0
        public static STOCK SingleOrDefault(Expression <Func <STOCK, bool> > expression)
        {
            var   repo    = GetRepo();
            var   results = repo.Find(expression);
            STOCK single  = null;

            if (results.Count() > 0)
            {
                single = results.ToList()[0];
                single.OnLoaded();
                single.SetIsLoaded(true);
                single.SetIsNew(false);
            }

            return(single);
        }
Пример #2
0
 void Init()
 {
     TestMode      = this._db.DataProvider.ConnectionString.Equals("test", StringComparison.InvariantCultureIgnoreCase);
     _dirtyColumns = new List <IColumn>();
     if (TestMode)
     {
         STOCK.SetTestRepo();
         _repo = _testRepo;
     }
     else
     {
         _repo = new SubSonicRepository <STOCK>(_db);
     }
     tbl = _repo.GetTable();
     SetIsNew(true);
     OnCreated();
 }
Пример #3
0
        internal static IRepository <STOCK> GetRepo(string connectionString, string providerName)
        {
            Solution.DataAccess.DataModel.SolutionDataBase_standardDB db;
            if (String.IsNullOrEmpty(connectionString))
            {
                db = new Solution.DataAccess.DataModel.SolutionDataBase_standardDB();
            }
            else
            {
                db = new Solution.DataAccess.DataModel.SolutionDataBase_standardDB(connectionString, providerName);
            }
            IRepository <STOCK> _repo;

            if (db.TestMode)
            {
                STOCK.SetTestRepo();
                _repo = _testRepo;
            }
            else
            {
                _repo = new SubSonicRepository <STOCK>(db);
            }
            return(_repo);
        }
Пример #4
0
 public static void Setup(STOCK item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }