Revision: 48299
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 28, 2011 17:56 by RichardCustance
Initial Code
Sage.Accounting.Application application = null; try { application = new Sage.Accounting.Application(); application.Connect("3", ""); application.ActiveCompany = application.Companies[1]; // Create an instnace of the model I want - in this case "Sage 200 Accounts" DataModel model = (new DataModelProvider()).CreateNew("Sage 200 Accounts",null); // Bind the connection bool bound=model.BindConnection(null); //Retrieve the context from the model Sage.Accounting.DataModel.DataContext context=(Sage.Accounting.DataModel.DataContext)(model.ModelContext); // The context for the Sage 200 Accounts model contains all of the entities you would expect // in addition to many calculated fields and projections context.SLCustomerAccounts.Select( s=>new { s.SLCustomerAccountID, s.CustomerAccountNumber, s.CustomerAccountShortName, s.AccountBalance, s.CreditLimit, s.SYSCurrencyID } ) .Dump(); } catch (System.Exception exception) { exception.Message.Dump(); } finally { if (application != null) { application.Disconnect(); } }
Initial URL
Initial Description
Initial Title
Using code to read data from model
Initial Tags
data
Initial Language
C#