public static IAsyncEnumerable<TEntity> LoadByKeyAsync<TEntity>(
this DbContext dataContext,
Object?[] parameters,
CancellationToken cancellationToken = default
)
where TEntity : class, new()
<ExtensionAttribute>
Public Shared Function LoadByKeyAsync(Of TEntity As {Class, New}) (
dataContext As DbContext,
parameters As Object(),
Optional cancellationToken As CancellationToken = Nothing
) As IAsyncEnumerable(Of TEntity)public:
[ExtensionAttribute]
generic<typename TEntity>
where TEntity : ref class, gcnew()
static IAsyncEnumerable<TEntity>^ LoadByKeyAsync(
DbContext^ dataContext,
array<Object^>^ parameters,
CancellationToken cancellationToken = CancellationToken()
)[<ExtensionAttribute>]
static member LoadByKeyAsync :
dataContext : DbContext *
parameters : Object[] *
?cancellationToken : CancellationToken
(* Defaults:
let _cancellationToken = defaultArg cancellationToken new CancellationToken()
*)
-> IAsyncEnumerable<'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 = await dataContext.LoadByKeyAsync<Asset>(assetKey).SingleAsync();