RepoDB icon indicating copy to clipboard operation
RepoDB copied to clipboard

Request: Some suggestions for future releases.

Open alper-atay opened this issue 5 years ago • 2 comments

IAsyncEnumerable suggestion

Hi, IAsyncEnumerable added with .Net Standard 2.1. So we can enumerate with await foreach on async operations. It is provides simplicity.

await foreach(var result in dbConnection.QueryAsSinglyAsync(whereQuery, ...))
{
  if(IsCorrectResult(result))
  {
    listBoxView.Add(result);
  }
  else 
  {
    continue;
  }

  if(listBoxView.ItemCount > 100)
 {
   break;
 }
}

If we have technical possibilities, UI applications get great facilities. Because all row don't getted. The user will see the result at that moment and approve it at their own discretion.

Proposal sample methods

public static IAsyncEnumerable<TResult> QueryAsSinglyAsync<TEntity, TResult>(...);
public static IAsyncEnumerable<TResult> QueryAllAsSinglyAsync<TEntity, TResult>(...);
public static IAsyncEnumerable<TResult> InsertAllAsSinglyAsync<TEntity, TResult>(...);
public static IAsyncEnumerable<TResult> UpdateAllAsSinglyAsync<TEntity, TResult>(...);
public static IAsyncEnumerable<TResult> DeleteAllAsSinglyAsync<TEntity, TResult>(...);
public static IAsyncEnumerable<TResult> UpdateAllAsSinglyAsync<TEntity, TResult>(...);

Select extensions methods

Proposal methods

TEntity entity = dbConnection.FirstOrDefault<TEntity>(object what); // For the primary key
TEntity entity = dbConnection.FirstOrDefault<TEntity>(queryGroup, fields, orderBy, ...); // For the querying. Fields is selected field like Select (Foo, Bar).

I am currently using

await dbConnection.QueryAsync<TModel>(Id, null, null, 1, Hints, Cacheable?.Key, Cacheable?.ItemExpiration, CommandTimeout, Transaction, Cacheable?.Cache, Trace, StatementBuilder).ContinueWith(x => x.Result.FirstOrDefault());

Purpose is simplicity. I think not need to First, Single, SingleOrDefault etc. That methods throw error on query return none. Just need to FirstOrDefault. We can understand result with null. (ref type default is null).

alper-atay avatar Sep 07 '20 11:09 alper-atay

Relating: https://github.com/mikependon/RepoDb/issues/338

mikependon avatar Sep 07 '20 11:09 mikependon

👍 Would love this, EF has it now

JoshZA avatar Apr 29 '22 19:04 JoshZA