ILoadable<TModel> Interface
.NET Standard 2.x
Provides a series of methods for manipulating data after loaded.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public interface ILoadable<TModel>;
Methods
Name | Return type | Description |
---|---|---|
FirstOrDefault() | TModel | Returns the first data record in the result set. If there is no data in the result set, returns the default value. |
Include(Expression<Func<TModel, object>> property, bool cascade = false) | ILoadable<TModel> | Loads data for the specified embedded property in TModel for all rows. |
Include(int index, Expression<Func<TModel, object>> property, bool cascade = false) | ILoadable<TModel> | Loads data for the specified embedded property in TModel for the specified row. |
IncludeAsync(Expression<Func<TModel, object>> property, bool cascade = false, CancellationToken cancellationToken = default) | Task<ILoadable<TModel>> | Asynchronously loads the specified embedded property in TModel for all rows. |
IncludeAsync(int index, Expression<Func<TModel, object>> property, bool cascade = false, CancellationToken cancellationToken = default) | Task<ILoadable<TModel>> | Asynchronously loads the specified embedded property in TModel for a specified row. |
IncludeAll(bool cascade = false) | ILoadable<TModel> | Loads data for the embedded properties in TModel for all rows. |
IncludeAll(int index, bool cascade = false) | ILoadable<TModel> | Loads data for the embedded properties in TModel for the specified row. |
IncludeAllAsync(bool cascade = false, CancellationToken cancellationToken = default) | Task<ILoadable<TModel>> | Asynchronously loads all the embedded properties in TModel for all rows. |
IncludeAllAsync(int index, bool cascade = false, CancellationToken cancellationToken = default) | Task<ILoadable<TModel>> | Asynchronously loads all the embedded properties in TModel for a specified row. |
ToArray() | TModel | Converts the result set to a new array. |
ToDictionary<TKey>(Func<TModel, TKey> keySelector) | Dictionary<TKey, TModel> | Creates a Dictionary<Tkey, TModel> from the result set according to the specified key selector function. |
ToList() | List<TModel> | Creates a List<TModel> from the result set. |
Remarks
Some methods of ISqlModelMapper
(e.g., ISqlModelMapper.Load and ISqlModelMapper.LoadByKey) can return an ILoadable
object whose methods can be used to manipulate the data.
For example, the ILoadable.ToList method can be used to convert the data to a list; the ILoadable.Include method can be used to load data for an embedded property.