public RateProcessor() { ratesList = new List <RateL2> { new RateL2() { Id = 1, Partner = "A", Supply = 100, ForexRate = 1.3M }, new RateL2() { Id = 2, Partner = "B", Supply = 50, ForexRate = 1.35M }, new RateL2() { Id = 3, Partner = "C", Supply = 20, ForexRate = 1.37M }, }; context = new ForexDbContext(); }
static void Main(string[] args) { using (var db = new ForexDbContext()) { //var trades = db.Trades.ToArray(); //var openDate = DateTime.Parse("01/04/2018 9:35:48"); //db.Trades.Add(new Trade("DImok", 1, 2, 10, 20, 100, openDate, openDate.AddSeconds(60 * 10 + 19),48)); //db.SaveChanges(); //foreach(var o in db.Trades) { // Console.WriteLine(new { o.Symbol, o.OpenPrice, o.ClosePrice, o.TimeOpen, o.TimeClose,o.PL } + ""); //} //Console.ReadKey(); //return; //Console.WriteLine(new { cd = "simulator::debug_realmicro 4", o = db.TraderModelPersist.Find("simulator::debug_realmicro 4") }.ToJson()); //db.TraderModelPersist.ToList().ForEach(o=>Console.WriteLine(o.ToJson())); db.ToDos.Add(new ToDo { What = "Debug", When = DateTime.UtcNow }); try { db.SaveChanges(); db.ToDos.First(x => x.What == "Debug").What = "Test"; db.SaveChanges(); var toDos = db.ToDos.ToArray(); foreach (var td in toDos) { Console.WriteLine($"{td.When.ToLocalTime().TimeOfDay}: {td.What}"); } db.RemoveRange(toDos.Reverse().Skip(4)); db.SaveChanges(); toDos = db.ToDos.ToArray(); toDos.First(x => x.What == "Debug").What = "Test " + DateTime.Now.Second; db.SaveChanges(); foreach (var td in db.ToDos) { Console.WriteLine($"{td.When.ToLocalTime().TimeOfDay}: {td.What}"); } } catch (Exception exc) { Console.WriteLine(exc + ""); } //db.Offer.Add(new Offer { OfferID = 1 }); //db.SaveChanges(); var offers = db.Offer.ToArray(); foreach (var o in offers) { Console.WriteLine(new { o.Pair, o.MMRLong } +""); } Console.ReadKey(); //var tms = db.TradingMacroSettings.ToArray(); //db.TradingMacroSettings.Add(new TradingMacroSettings { Pair = "Dimok", PairIndex = 1 }); //db.SaveChanges(); //foreach(var o in tms) { // Console.WriteLine(new { o.Pair, o.PairIndex } + ""); //} } }
public void Dispose() { if (dbContext == null) { return; } dbContext.Dispose(); dbContext = null; }
public RateProcessor(int quantity) { context = new ForexDbContext(); newRates = new List <RateL3>(); rates = context.L3Rates.ToList(); originalQuantity = quantity; qty = quantity; }
public Repository(ForexDbContext context) { _context = context; _dbSet = _context.Set <T>(); }
public static void Initialize() { DbContext = ForexDbContext.GetInstance(); }
public UnitOfWork(ForexDbContext context) { _context = context; }