public bool Exists(IStockProfile stockProfile) { StockProfileRepository repository = new StockProfileRepository(DataFiles.GetStockProfileFile()); return repository.Exists(stockProfile); //// 设置查询条件 //var spec = Specification<StockProfile>.Eval(p => p.CodeA.Equals(stockProfile.CodeA)); //using (var context = GetContext()) //{ // var repository = new Repository<StockProfile>(context); // return repository.Exists(spec); //} }
public void TestMethod_StockProfile() { StockProfile example = ExampleStockProfile(); string filePath = Path.Combine(Environment.CurrentDirectory, "TestStockProfile.sdf"); if (File.Exists(filePath)) { File.Delete(filePath); } StockProfileRepository repository = new StockProfileRepository(filePath); repository.AddRange(new IStockProfile[] { example }); Assert.IsTrue(repository.Exists(example)); IStockProfile get = repository.Get(example.CodeA); StockProfile updateData = example; updateData.ShortNameA = "招商银行_UpdateTest"; repository.UpdateRange(new IStockProfile[] { updateData }); Assert.IsTrue(repository.Exists(updateData)); IList<IStockProfile> result = repository.GetAll().ToList(); Assert.AreEqual(1, result.Count); }