fcs-utils/IRepositoryEx.cs

127 lines
4.6 KiB
C#
Raw Normal View History

2020-10-19 11:22:06 +02:00
// ***********************************************************************
2022-02-24 11:57:37 +01:00
// Assembly : FCS.Lib.Utility
2020-10-19 11:22:06 +02:00
// Author : FH
// Created : 03-10-2015
//
// Last Modified By : FH
2022-02-24 11:40:38 +01:00
// Last Modified On : 02-24-2022
2020-10-19 11:22:06 +02:00
// ***********************************************************************
// <copyright file="IRepositoryEx.cs" company="FCS">
2022-02-24 10:11:45 +01:00
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
2022-01-01 16:57:37 +01:00
//
2022-02-24 10:11:45 +01:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
2022-01-01 16:57:37 +01:00
//
2022-02-24 10:11:45 +01:00
// You should have received a copy of the GNU Affero General Public License
2022-02-24 14:00:27 +01:00
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
2022-02-24 10:11:45 +01:00
// </copyright>
// <summary></summary>
2020-10-19 11:22:06 +02:00
// ***********************************************************************
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
2022-02-24 11:40:38 +01:00
namespace FCS.Lib.Utility
2020-10-19 11:22:06 +02:00
{
/// <summary>
2022-02-04 08:39:06 +01:00
/// Interface IRepositoryEx
2020-10-19 11:22:06 +02:00
/// </summary>
/// <typeparam name="TEntity">The type of the t entity</typeparam>
public interface IRepositoryEx<TEntity> where TEntity : class
{
/// <summary>
2021-11-06 11:16:18 +01:00
/// Get all entities synchronous
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="predicate">Predicate</param>
/// <returns>Task&lt;System.Boolean&gt;</returns>
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
2021-11-06 11:16:18 +01:00
/// Find matching entity asynchronous
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="predicate">Predicate</param>
/// <returns>Task&lt;TEntity&gt;</returns>
Task<TEntity> FindAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
2021-11-06 11:16:18 +01:00
/// Find first matching entity asynchronous
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="predicate">Predicate</param>
/// <returns>Task&lt;TEntity&gt;</returns>
Task<TEntity> FirstAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
2021-11-06 11:16:18 +01:00
/// Get first entity matching query or default entity asynchronous
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="predicate">Predicate</param>
/// <returns>Task&lt;TEntity&gt;</returns>
Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
2021-11-06 11:16:18 +01:00
/// Add an entity
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="entity">The entity.</param>
void Add(TEntity entity);
/// <summary>
2021-11-06 11:16:18 +01:00
/// Attach the entity
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="entity">The entity.</param>
void Attach(TEntity entity);
/// <summary>
2021-11-06 11:16:18 +01:00
/// Delete the entity
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="entity">The entity.</param>
void Delete(TEntity entity);
/// <summary>
2021-11-06 11:16:18 +01:00
/// Anies the specified predicate.
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="predicate">The predicate.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
bool Any(Expression<Func<TEntity, bool>> predicate);
/// <summary>
2022-01-01 17:22:01 +01:00
/// Get entity by id
2020-10-19 11:22:06 +02:00
/// </summary>
2022-01-01 17:22:01 +01:00
/// <param name="id">The identifier.</param>
/// <returns>TEntity</returns>
TEntity GetById(string id);
2020-10-19 11:22:06 +02:00
/// <summary>
2021-11-06 11:16:18 +01:00
/// Find first entity matching query
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="predicate">Predicate</param>
/// <returns>TEntity</returns>
TEntity First(Expression<Func<TEntity, bool>> predicate);
/// <summary>
2021-11-06 11:16:18 +01:00
/// Find first matching entity or default entity
2020-10-19 11:22:06 +02:00
/// </summary>
/// <param name="predicate">Predicate</param>
/// <returns>TEntity</returns>
TEntity FirstOrDefault(Expression<Func<TEntity, bool>> predicate);
/// <summary>
2022-01-01 17:22:01 +01:00
/// Find all matching entities matching query
2020-10-19 11:22:06 +02:00
/// </summary>
2022-01-01 17:22:01 +01:00
/// <param name="predicate">Predicate</param>
/// <returns>IQueryable&lt;TEntity&gt;</returns>
IQueryable<TEntity> Find(Expression<Func<TEntity, bool>> predicate);
/// <summary>
/// Get all entities
/// </summary>
/// <returns>IQueryable&lt;TEntity&gt;</returns>
IQueryable<TEntity> All();
2020-10-19 11:22:06 +02:00
}
}