Skip to main content
.NET 6.0+

Session.GetObjectsByKeyFromSprocParametrized(XPClassInfo, Boolean, String, SprocParameter[]) Method

Returns persistent objects with the keys loaded with the specified stored procedure.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.1.dll

NuGet Package: DevExpress.Xpo

Declaration

public ICollection GetObjectsByKeyFromSprocParametrized(
    XPClassInfo classInfo,
    bool alwaysGetFromDataStore,
    string sprocName,
    params SprocParameter[] parameters
)

Parameters

Name Type Description
classInfo XPClassInfo

The metadata information of the persistent objects that are retrieved based on the stored procedure results.

alwaysGetFromDataStore Boolean

true to always reload persistent objects from storage; otherwise, false.

sprocName String

The stored procedure name.

parameters DevExpress.Xpo.DB.SprocParameter[]

An array of parameters to pass to the stored procedure.

Returns

Type Description
ICollection

A collection of persistent objects with specified key property values.

Remarks

First, the GetObjectsByKeyFromSprocParametrized method executes the specified stored procedure with parameters and retrieves key property values into a result set. Then, the method searches in memory for persistent objects with retrieved key property values. If such objects are found, they are not reloaded. To get the up-to-date objects from storage, the alwaysGetFromDb parameter must be set to true.

The GetObjectsByKeyFromSprocParametrized method may throw the InvalidCastException if the key value type does not match the key property type. Select key values from a column of a type mapped to a key property type to avoid this error. The following article describes how XPO maps a CLR type to a database type: Data Types Supported by XPO.

ADO.NET data readers may use different mappings between CLR and database types. XPO mappings are actual for the following key property types: Int32, Int64, Guid. When working with other key property types, ensure that the corresponding ADO.NET data reader returns values of an appropriate type. Use the ExecuteSprocParametrized and GetObjectsByKey methods instead of GetObjectsByKeyFromSprocParametrized when the type conversion is required.

Note

The GetObjectsByKeyFromSprocParametrized method does not find objects until they are saved to a data store.

For more informatioon about executing stored procedures in XPO, refer to Stored Procedures.

See Also