public void TestMethod_Participation() { Participation example_600036 = ExampleParticipation_600036(new DateTime(2016, 1, 1)); Participation example_600518 = ExampleParticipation_600518(new DateTime(2016, 1, 1)); string filePath = Path.Combine(Environment.CurrentDirectory, "TestParticipation.sdf"); if (File.Exists(filePath)) { File.Delete(filePath); } ParticipationRepository repository = new ParticipationRepository(filePath); repository.AddRange(new IParticipation[] { example_600036 }); Assert.IsTrue(repository.Exists(example_600036)); Assert.IsFalse(repository.Exists(ExampleParticipation_600036(new DateTime(2016, 2, 1)))); IParticipation get = repository.Get(example_600036.Time.ToString("yyyy-MM-dd HH:mm:ss")); Participation updateData = example_600518; repository.UpdateRange(new IParticipation[] { updateData }); Assert.IsTrue(repository.Exists(updateData)); updateData.CostPrice1Day = 100.00; repository.UpdateRange(new IParticipation[] { updateData }); updateData.CostPrice20Day = 200.00; repository.UpdateRange(new IParticipation[] { updateData }); IList<IParticipation> result = repository.GetAll().ToList(); Assert.AreEqual(1, result.Count); }
public IEnumerable<IParticipation> Get(string stockCode) { ParticipationRepository repository = new ParticipationRepository(DataFiles.GetParticipationFile(stockCode)); return repository.GetAll(); //using (var context = GetContext(stockCode)) //{ // var repository = new Repository<Participation>(context); // return repository.GetAll(); //} }
public void Update(string stockCode, IParticipation participation) { ParticipationRepository repository = new ParticipationRepository(DataFiles.GetParticipationFile(stockCode)); repository.UpdateRange(new IParticipation[] { participation }); //using (var context = GetContext(stockCode)) //{ // var repository = new Repository<Participation>(context); // repository.Update(participation.ToDataObject()); // repository.UnitOfWork.Commit(); //} }
public bool Exists(string stockCode, IParticipation participation) { ParticipationRepository repository = new ParticipationRepository(DataFiles.GetParticipationFile(stockCode)); return repository.Exists(participation); //// 设置查询条件 //var spec = Specification<Participation>.Eval(p => p.Time.Equals(participation.Time)); //using (var context = GetContext(stockCode)) //{ // var repository = new Repository<Participation>(context); // return repository.Exists(spec); //} }