Retrieving a List of Business Entities with GetEntityList()
There are several overloads of GetEntityList() that allow you to retrieve a list of entity objects.
GetEntityList() automatically stores the reference to the retrieved entity in the business object's EntityList property.
GetEntityList()
Entity Framework Only
- Retrieves a list of entities of the default type by executing the specified object query
protected virtual mmBindingList<EntityType> GetEntityList(IQueryable<EntityType> objectQuery)
- Retrieves a list of entities of the specified type by executing the specified object query
protected virtual mmBindingList<T> GetEntityList<T>(IQueryable<T> objectQuery) where T : class
Example 1 - Entity Framework
In the following code sample, GetEntityList() is called passing an object query and returns a list of OrderEntity objects:
In C#:
/// <summary> /// Returns a strongly typed list of OrderEntity objects for the specified customer /// </summary> /// <param name="customerID">Customer ID</param> /// <returns>Strongly Typed List of OrderEntity objects</returns> public mmBindingList<OrderEntity> GetOrdersByCustomerID(string customerID) { IQueryable<OrderEntity> query = from order in this.ObjectContext.OrderEntitySet where order.CustomerID == customerID select order; return this.GetEntityList<OrderEntity>(query); }
In VB .NET:
Public Function GetOrdersByCustomerID(ByVal customerID As String) As mmBindingList(Of OrderEntity) Dim query As IQueryable(Of OrderEntity) = From order In Me.ObjectContext.OrderEntitySet Where order.CustomerID = customerID Select order Return Me.GetEntityList(query) End Function
MM .NET "Classic Entities" Only
- Returns a list of Business Entity objects of the default EntityType containing the results of the command string (based on the DefaultCommandType) executed against the default database
protected virtual mmBindingList<EntityType> GetEntityList(string command)
- Returns a list of Business Entity objects of the default EntityType containing the results of the command string (based on the DefaultCommandType) w/ parameters executed against the default database
protected virtual mmBindingList<EntityType> GetEntityList(string command, params IDbDataParameter[] cmdParams)
- Returns a list of Business Entity objects of the default EntityType containing the results of the command string (based on the specified command type) executed against the default database.
protected virtual mmBindingList<EntityType> GetEntityList(string command, CommandType cmdType)
- Returns a list of Business Entity objects of the default EntityType containing the results of the command string (based on the specified command type) executed against the specified database.
protected virtual mmBindingList<EntityType> GetEntityList(string command, string databaseKey, CommandType cmdType)
- Returns a list of Business Entity objects of the default EntityType containing the results of the command string (based on DefaultCommandType) executed against the specified database.
protected virtual mmBindingList<EntityType> GetEntityList(string command, string databaseKey)
- Returns a list of Business Entity objects of the default EntityType containing the results of the command (based on the DefaultCommandType) w/ parameters executed against the specified database
protected virtual mmBindingList<EntityType> GetEntityList(string command, string databaseKey, params IDbDataParameter[] cmdParams)
- Returns list of Business Entity objects of the default EntityType containing the results of the command (based on the specified command type) w/ parameters executed against the default database
protected virtual mmBindingList<EntityType> GetEntityList(string command, CommandType cmdType, params IDbDataParameter[] cmdParams)
- Returns a list of Business Entity objects of the default EntityType containing the results of the command (based on the specified command type) w/ parameters executed against the specified database
protected virtual mmBindingList<EntityType> GetEntityList(string command, string databaseKey, CommandType cmdType, params IDbDataParameter[] cmdParams)
Example 1 - Classic Entities
In the following code sample GetEntityList() is called passing a stored procedure that accepts a parameter and returns a list of OrdersEntity objects. This assumes the business object's DefaultCommandType (usually specified at the ABusinessObject level) is set to CommandType.StoredProcedure:
In C#:
public mmBindingList<OrderEntity> GetOrdersByCustomerID(string customerID) { return this.GetEntityList("OrdersSelectByCustomerID", this.CreateParameter("@CustomerID", customerID)); }
In VB .NET:
Public Function GetOrdersByCustomerID(ByVal customerID As String) As mmBindingList(Of OrderEntity) Return Me.GetEntityList("OrdersSelectByCustomerID", _ Me.CreateParameter("@CustomerID", customerID)) End Function
Example 2 - Classic Entities
In the following code sample GetEntityList() is called passing a dynamic SQL statement that accepts a parameter and returns a list of OrdersEntity objects. This assumes the business object's default command type (usually specified at the ABusinessObject level) is set to CommandType.Text:
In C#:
public mmBindingList<OrderEntity> GetOrdersByCustomerID(string customerID) { return this.GetEntityList("SELECT * FROM Orders WHERE CustomerID = @CustomerID", this.CreateParameter("@CustomerID", customerID)); }
And in VB .NET:
Public Function GetOrdersByCustomerID(ByVal customerID As String) As mmBindingList(Of OrderEntity) Return Me.GetEntityList("SELECT * FROM Orders WHERE CustomerID = @CustomerID", Me.CreateParameter("@CustomerID", customerID)) End Function
See also:
Retrieving Business Entity Objects with GetEntity()
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 06/25/18
Comment or report problem with topic
