DataConnector | ComponentOne
ADO.NET provider for QuickBooks Online / LINQ Queries
In This Topic
    LINQ Queries
    In This Topic

    LINQ queries demonstrate how to operate and query the QuickBooks Online objects wrapped in an Entity Framework data model. Listed below are some examples of LINQ queries supported by the Entity framework.

    Contains

    Retrieve all entities that contain "A" in the Note column

    C#
    Copy Code
    var records = from p in context.Attachables
                  where p.Note.Contains("A") //using Contains to display Notes that have "A"
                  select p;
    Count

    Count all entities that match a given criterion

    C#
    Copy Code
    var _count = (from p in context.Attachables
                  select p).Count(); //Count Query based on the number of records selected
    Select and Filter

    Select a record with a specific Id

    C#
    Copy Code
    var records = from p in context.Attachables
                  where p.Id == "5000000000000504413"
                  select p;
    Limit

    Select the first 10 records

    C#
    Copy Code
    var records = (from p in context.Attachables
                   select p).Take(10); //taking 10 records
    Order By

    Sort data by Size in descending order.

    C#
    Copy Code
    var records = (from p in context.Attachables
                   orderby p.Size descending //Implementing Order By
                   select p).Take(10); //taking 10 records
    Group By

    Group records from the Attachables table based on the Category property. The groups are then ordered in descending order based on the Category.

    C#
    Copy Code
    var attachablesTable = context.Attachables.AsEnumerable();
    var queryAttachables = from b in attachablesTable
                           group b by b.Category into newGroup
                           orderby newGroup.Key descending
                           select newGroup;
    Joins

    Cross-join PurchaseOrders and Purchases tables.

    C#
    Copy Code
    var records = from b in context.PurchaseOrders
                  from e in context.Purchases
                  select new { b, e }; //Defining Cross Join