Get Data

Getting Data Programmatically

Before you begin, make sure you have created a global data type "Demo.User" with one field of the String type named "Name" and some data or update the code in the sample to refer to an actual data type and its fields.

Sample:

using System.Linq;
using Composite.Data;

namespace Demo
{
    public class Class4
    {
        public static IQueryable<Demo.User> GetData(string userName)
        {
            using (DataConnection connection = new DataConnection())
            {
                var myUsers =
                   from d in connection.Get<Demo.User>()
                   where d.Name == userName
                   select d;

                return myUsers;
            }
        }
    }
}

Download the source

In this sample, we use DataConnection to query for Demo.Users (Get) with a specific name (Name) and return them as IQueryable <Demo.User>.

Read more on Composite.Data.DataConnection and its member methods

Please also see How to Query Data Using LINQ.