TradePlatformModel

Adding reference to TradePlatform.MT4.Data.dll gives you opportunity to use Entity Framework approach. There are already entity classes for Accounts and Orders there as well as connection string sample in Gateway Configuration.

You only need to create database and use TradePlatformModel.edmx.sql script to create tables and mention path to MDF file in your Gateway Configuration and Data tier is ready to go.

Short sample demonstrates how to use Entity Framework with .NET ExpertAdvisor below:

 using (TradePlatformEntities model = new TradePlatformEntities())
 {
      int currentNumber = this.AccountNumber();
      Account account = model.Accounts
.SingleOrDefault(x => x.AccountNumber == currentNumber); if (account == null) { account = new Account(); model.Accounts.AddObject(account); } account.AccountBalance = this.AccountBalance(); account.AccountCredit = this.AccountCredit(); account.AccountCompany = this.AccountCompany(); account.AccountCurrency = this.AccountCurrency(); account.AccountEquity = this.AccountEquity(); account.AccountFreeMargin = this.AccountFreeMargin(); account.AccountFreeMarginMode = this.AccountFreeMarginMode(); account.AccountLeverage = this.AccountLeverage(); account.AccountMargin = this.AccountMargin(); account.AccountName = this.AccountName(); account.AccountNumber = this.AccountNumber(); account.AccountProfit = this.AccountProfit(); account.AccountServer = this.AccountServer(); account.AccountStopoutLevel = this.AccountStopoutLevel(); account.AccountStopoutMode = this.AccountStopoutMode(); model.SaveChanges(); }

You can also check out Model Project to see detailed Entity Framework example.

Last edited Sep 24, 2012 at 12:56 PM by vladkalos, version 5

Comments

No comments yet.