Below is a list of LINQ statements that will help to get a quick start with LINQ2DYNAMICS

LINQ builds on the .NET business connector and requires the user to be on the same domain or have access rights through a trusted domain in order to validate the user credentials. It also a requirement that the Dynamics Ax business connector is installed.

Include the Using LittleBeacon; statement in the top of the project.

AxQueryProxy axapta = new AxQueryProxy("","","","").

The axapta object can now be used from within the LINQ statement.

 

 

 

var custTable = from cust in axapta.CustTable
                select new
{ cust.AccountNum, cust.Name, cust.City};

or

var custTable = from cust in axapta.CustTable
                     select cust;

 

 var custTable = from cust in axapta.CustTable
                      where cust.City == "Toronto"
                      select new { cust.AccountNum, cust.Name, cust.City};

 

 var custTable = from cust in axapta.CustTable
                      orderby cust.Name
                      select new { cust.AccountNum, cust.Name, cust.City};

var custTable = from cust in axapta.CustTable

               join trans in axapta.CustTrans
        on cust.AccountNum equals trans.AccountNum 

select new {trans.TransDate,trans.AmountMST, cust.AccountNum};

Below is a sample of the syntax on how to sum values together

var qs = axapta.CustTrans.Where(g => g.TransType == LedgerTransType.Cust
                        && g.Invoice != "").Select(g => g.AmountCur).Sum();

Below is a sample of the syntax on how to count transactions

var qs = axapta.CustTrans.Where(g => g.TransType == LedgerTransType.Cust)

                        .Select(g => g.AmountCur).Count();

Below is a sample on the syntax on how to get averages

var qs = axapta.CustTrans.Where(g => g.TransType == LedgerTransType.Cust)

                        .Select(g => g.AmountCur).Average();