Read All Columns

Syntax

Get(filter, orderBy, includeProperties, rows);

Arguments

filter

Expression<Func<T, bool>>

Criteria by which the records of the repository should be filtered.

This parameter must not be empty.

null

orderBy

Func<IQueryable, IOrderedQueryable>

Order in which the filtered records should be listed.

This parameter is optional.

null

includeProperties

string

Navigation properties (recognized by the key word "virtual") that should be included.

This parameter is optional.

""

rows

int

Maximal number of records that should be filtered.

This parameter is optional.

0

Description

Gets all records from a repository that fulfill the criteria specified in the parameter filter. (Because it loads all columns instead of just specific ones, it is usually slower than "GetFields".)

If orderBy is not null, it first orders the records according to the attributes specified in the parameter orderBy before getting the records from the newly ordered list.

If includeProperties is not null, it additionally loads the navigation properties that are specified in the parameter includeProperties. Navigation properties are "virtual" properties of the repository, i.e. they are not real properties and are accessed by navigating to another object. They would not get loaded unless specified in this parameter.

If rows is not 0, it makes sure that the number of filtered records does not exceed the specified number.

Example

Example 1: Filtering records by only one criterion

The following program illustrates the function call with only one criterion:

var orderList = repo.Get(x => x.ProductID == "ADAM-567-BTO");

Function will load all the records from the repository that have "ADAM-567-BTO" as Production ID and store the result into the variable "orderList".

Example 2: Filtering records by multiple criteria

The following program illustrates the function call with multiple criteria:

var orderList = repo.Get(x => x.ProductID == "ADAM-567-BTO" 
                           && x.Quantity > 10 
                           && x.IsUrgent == true);

Function will load all the records from the repository that have "ADAM-567-BTO" as Production ID, have a Quantity of more than 10 and are Urgent, and store the result into the variable "orderList".

Example 3: Filtering records by multiple criteria with order

The following program illustrates the function call with multiple criteria and specified order:

var orderList = repo.Get(x => x.ProductID == "ADAM-567-BTO" 
                           && x.Quantity > 10, 
                       o => o.OrderBy(c => c.Timestamp);

Function will order the records by their Timestamp attribute, load all the records from the ordered repository that have "ADAM-567-BTO" as Production ID and a Quantity of more than 10, and store the result into the variable "orderList".

Example 4: Filtering records by multiple criteria with order + maximum limit

The following program illustrates the function call with multiple criteria, specified order and maximum limit:

var orderList = repo.Get(x => x.ProductID == "ADAM-567-BTO" 
                           && c.Quantity > 10, 
                         o => o.OrderBy(c => c.Timestamp), 
                         "",
                         100);

Function will order the records by their Timestamp attribute, load a maximum of 100 records from the ordered repository that have "ADAM-567-BTO" as Production ID and a Quantity of more than 10, and store the result into the variable "orderList".

Example 5: Filtering records by multiple criteria with order + maximum limit and including an virtual property

The following program illustrates the function call with multiple criteria, specified order, maximum limit and external property:

var orderList = repo.Get(x => x.ProductID == "ADAM-567-BTO" 
                           && c.Quantity > 10, 
                         o => o.OrderBy(c => c.Timestamp), 
                         "SapOrder",
                         100);

Function will order the records by their Timestamp attribute, load a maximum of 100 records from the ordered repository that have "ADAM-567-BTO" as Production ID and a Quantity of more than 10, include the virtual property "SapOrder" (a navigation property of "Production Order") and store the result into the variable "orderList".

Last updated