initial commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Application.Common.Extensions;
|
||||
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static string ToFriendlyName<TEnum>(this TEnum value) where TEnum : Enum
|
||||
{
|
||||
var memberInfo = typeof(TEnum).GetMember(value.ToString());
|
||||
var descriptionAttribute = memberInfo[0]
|
||||
.GetCustomAttribute<DescriptionAttribute>();
|
||||
|
||||
return descriptionAttribute?.Description ?? value.ToString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Domain.Common;
|
||||
|
||||
namespace Application.Common.Extensions;
|
||||
|
||||
|
||||
public static class QueryableExtensions
|
||||
{
|
||||
public static IQueryable<T> ApplyIsDeletedFilter<T>(this IQueryable<T> query, bool isDeleted = false) where T : class
|
||||
{
|
||||
if (typeof(IHasIsDeleted).IsAssignableFrom(typeof(T)))
|
||||
{
|
||||
query = query.Where(x => (x as IHasIsDeleted)!.IsDeleted == isDeleted);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user