Session.GetObjectsByKeyFromSproc(XPClassInfo, Boolean, String, OperandValue[]) Method
Returns reloaded persistent objects from a data store, with key property values obtained via the specified stored procedure.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.1.dll
NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap, DevExpress.Xpo
NuGet Package: DevExpress.Xpo
Declaration
Parameters
Name | Type | Description |
---|---|---|
classInfo | XPClassInfo | An XPClassInfo object which contains the metadata information of the persistent objects that are retrieved based on the stored procedure’s results. |
alwaysGetFromDataStore | Boolean | true to reload persistent objects from storage, if they are found in memory; otherwise, false. |
sprocName | String | A String value that specifies the stored procedure’s name. |
parameters | OperandValue[] | 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
The GetObjectsByKeyFromSproc method works as follows:
- Executes the specified stored procedure with parameters and retrieves key property values into a result set.
- 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, set the alwaysGetFromDb parameter to
true
.
The GetObjectsByKeyFromSproc 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 ExecuteSproc and GetObjectsByKey methods instead of GetObjectsByKeyFromSproc when the type conversion is required.
Note
The GetObjectsByKeyFromSproc 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.