public static IEnumerable<TEntity> LoadByKey<TEntity>(
this DbContext dataContext,
params Object?[] parameters
)
where TEntity : class, new()
<ExtensionAttribute>
Public Shared Function LoadByKey(Of TEntity As {Class, New}) (
dataContext As DbContext,
ParamArray parameters As Object()
) As IEnumerable(Of TEntity)public:
[ExtensionAttribute]
generic<typename TEntity>
where TEntity : ref class, gcnew()
static IEnumerable<TEntity>^ LoadByKey(
DbContext^ dataContext,
... array<Object^>^ parameters
)[<ExtensionAttribute>]
static member LoadByKey :
dataContext : DbContext *
parameters : Object[] -> IEnumerable<'TEntity> when 'TEntity : not struct, new()The stored procedure name is determined by looking for the LoadByKeyStoredProcedureAttribute on the entity type. If the attribute is not present, the stored procedure name is assumed to be the same as the entity type name without the ResultSetSuffix property value. The stored procedure must have a parameter for each of the passed key values in parameters.
If the connection is not in an open state, it is opened temporarily while loading the entities. If change tracking is enabled on the data context, changes to the entities will be tracked. If not, they will not be tracked.
using var dataContext = new MyDbContext();
var assetInfo = dataContext.LoadByKey<Asset>(assetKey).Single();