143 lines
4.5 KiB
C#
143 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq.Expressions;
|
|
using System.Threading.Tasks;
|
|
using xModels.Base;
|
|
|
|
namespace xModels.Interfaces {
|
|
public interface IXBaseStore<T, TKey> where T : XBaseStorableDto<TKey> {
|
|
//
|
|
#region Retrieve ...
|
|
/// <summary>
|
|
/// Retrieve all Exists Items ...
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<T>> GetAll ();
|
|
|
|
/// <summary>
|
|
/// Retrieve specific Item by key ...
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
Task<T> Get (TKey key);
|
|
|
|
/// <summary>
|
|
/// retrieve items based on specific condition ...
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<T>> FindMany (Expression<Func<T, bool>> condition);
|
|
|
|
/// <summary>
|
|
/// retrieve item based on specific condition ...
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
Task<T> FindOne (Expression<Func<T, bool>> condition);
|
|
#endregion
|
|
|
|
//
|
|
#region Add ...
|
|
/// <summary>
|
|
/// add specific item to Store ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <returns></returns>
|
|
Task<bool> Add (T item);
|
|
|
|
/// <summary>
|
|
/// Add a Collection of Items on Store ...
|
|
/// </summary>
|
|
/// <param name="items"></param>
|
|
/// <returns></returns>
|
|
Task<bool> AddMany (XBaseRangeRequest<T> items);
|
|
#endregion
|
|
|
|
//
|
|
#region Remove ...
|
|
/// <summary>
|
|
/// Remove an item from store ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <returns></returns>
|
|
Task<bool> Remove (T item);
|
|
|
|
/// <summary>
|
|
/// remove an item by it's Key ...
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
Task<bool> RemoveByKey (TKey key);
|
|
|
|
/// <summary>
|
|
/// remove a collection of items at once ...
|
|
/// </summary>
|
|
/// <param name="items"></param>
|
|
/// <returns></returns>
|
|
Task<bool> RemoveMany(XBaseRangeRequest<T> items);
|
|
#endregion
|
|
|
|
//
|
|
#region Update ...
|
|
/// <summary>
|
|
/// Update Exists Item in store ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="propertyWhiteList"></param>
|
|
/// <param name="propertyBlackList"></param>
|
|
/// <param name="propertyValueProviders"></param>
|
|
/// <param name="updateWithNullOrEmptyValues"></param>
|
|
/// <returns></returns>
|
|
Task<T> Update (
|
|
T item,
|
|
ICollection<string> propertyWhiteList = null,
|
|
ICollection<string> propertyBlackList = null,
|
|
ICollection<KeyValuePair<string, Func<T, object>>> propertyValueProviders = null,
|
|
bool updateWithNullOrEmptyValues = false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Update a Collection of Exists Items ...
|
|
/// </summary>
|
|
/// <param name="items"></param>
|
|
/// <param name="propertyWhiteList"></param>
|
|
/// <param name="propertyBlackList"></param>
|
|
/// <param name="propertyValueProviders"></param>
|
|
/// <param name="updateWithNullOrEmptyValues"></param>
|
|
/// <returns></returns>
|
|
Task<bool> UpdateMany (
|
|
XBaseRangeRequest<T> items,
|
|
ICollection<string> propertyWhiteList = null,
|
|
ICollection<string> propertyBlackList = null,
|
|
ICollection<KeyValuePair<string, Func<T, object>>> propertyValueProviders = null,
|
|
bool updateWithNullOrEmptyValues = false
|
|
);
|
|
#endregion
|
|
|
|
//
|
|
#region Exists ...
|
|
/// <summary>
|
|
/// retrieve item(s) exists based on specific condition ...
|
|
/// </summary>
|
|
/// <param name="condition"></param>
|
|
/// <returns></returns>
|
|
Task<bool> IsExists (Expression<Func<T, bool>> condition);
|
|
|
|
/// <summary>
|
|
/// is exists an item by providing it's key ...
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
Task<bool> IsExistsByKey (TKey key);
|
|
#endregion
|
|
|
|
//
|
|
#region Count ...
|
|
/// <summary>
|
|
/// Count Exists items ...
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
Task<int> Count ();
|
|
#endregion
|
|
}
|
|
} |