public IEnumerable<IStockStructure> Get(string stockCode)
        {
            StockStructureRepository repository = new StockStructureRepository(DataFiles.GetStockStructureFile(stockCode));
            return repository.GetAll();

            //using (var context = GetContext(stockCode))
            //{
            //    var repository = new Repository<StockStructure>(context);
            //    return repository.GetAll();
            //}
        }
        public void Update(string stockCode, IStockStructure stockStructure)
        {
            StockStructureRepository repository = new StockStructureRepository(DataFiles.GetStockStructureFile(stockCode));
            repository.UpdateRange(new IStockStructure[] { stockStructure });

            //using (var context = GetContext(stockCode))
            //{
            //    var repository = new Repository<StockStructure>(context);
            //    repository.Update(stockStructure.ToDataObject());
            //    repository.UnitOfWork.Commit();
            //}
        }
        public bool Exists(string stockCode, IStockStructure stockStructure)
        {
            StockStructureRepository repository = new StockStructureRepository(DataFiles.GetStockStructureFile(stockCode));
            return repository.Exists(stockStructure);

            //// 设置查询条件
            //var spec = Specification<StockStructure>.Eval(p => p.DateOfChange.Equals(stockStructure.DateOfChange));

            //using (var context = GetContext(stockCode))
            //{
            //    var repository = new Repository<StockStructure>(context);
            //    return repository.Exists(spec);
            //}
        }
Exemple #4
0
        public void TestMethod_StockStructure()
        {
            List<IStockStructure> example_600036 = ExampleStockStructure_600036();
            List<IStockStructure> example_600518 = ExampleStockStructure_600518();

            string filePath = Path.Combine(Environment.CurrentDirectory, "TestStockStructure.sdf");
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
            StockStructureRepository repository = new StockStructureRepository(filePath);
            repository.AddRange(example_600036);

            IStockStructure get = repository.Get(example_600036[0].DateOfChange.ToString("yyyy-MM-dd HH:mm:ss"));

            Assert.IsTrue(repository.Exists(example_600036[0]));
            Assert.IsFalse(repository.Exists(example_600518[0]));

            StockStructure updateData = example_600036[0] as StockStructure;
            updateData.Reason = "TestMethod_StockStructure";

            repository.UpdateRange(new IStockStructure[] { updateData });
            IList<IStockStructure> result0 = repository.GetAll().ToList();

            Assert.IsTrue(repository.Exists(updateData));

            List<IStockStructure> updateDatas = GetUpdateDatas(example_600036).ToList();
            repository.UpdateRange(updateDatas);

            IList<IStockStructure> result = repository.GetAll().ToList();
            Assert.AreEqual(example_600036.Count, result.Count);
        }