add load-as-list to raven operations
This commit is contained in:
@@ -42,6 +42,27 @@ public partial class RavenOperations : IRavenOperations
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : ZeroIdEntity, new()
|
||||
{
|
||||
ids = ids.Distinct().ToArray();
|
||||
|
||||
Dictionary<string, T> models = await Session.LoadAsync<T>(ids);
|
||||
List<T> result = new();
|
||||
|
||||
foreach (string id in ids)
|
||||
{
|
||||
models.TryGetValue(id, out T model);
|
||||
if (WhenActive(model) != null)
|
||||
{
|
||||
result.Add(model);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<bool> Any<T>(Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : ZeroIdEntity, new()
|
||||
{
|
||||
|
||||
@@ -183,6 +183,11 @@ public interface IRavenOperations
|
||||
/// </summary>
|
||||
Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : ZeroIdEntity, new();
|
||||
|
||||
/// <summary>
|
||||
/// Get entities by ids
|
||||
/// </summary>
|
||||
Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : ZeroIdEntity, new();
|
||||
|
||||
/// <summary>
|
||||
/// Get entities by query
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user