修改仓储
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace IRaCIS.Core.Infrastructure.Extention
|
||||
{
|
||||
public static class NUllCheckExtension
|
||||
{
|
||||
|
||||
|
||||
[DoesNotReturn]
|
||||
public static TEntity IfNullThrowException<TEntity>(this TEntity businessObject) where TEntity : class
|
||||
{
|
||||
if(businessObject == null)
|
||||
{
|
||||
throw new QueryBusinessObjectNotExistException($"The query object {typeof(TEntity).Name} does not exist , or was deleted by someone else, or an incorrect parameter query caused");
|
||||
}
|
||||
else
|
||||
{
|
||||
return businessObject!;
|
||||
}
|
||||
}
|
||||
|
||||
[DoesNotReturn]
|
||||
public static TEntity IfNullThrowException<TEntity>(this TEntity? businessStruct) where TEntity : struct
|
||||
{
|
||||
if (businessStruct == null)
|
||||
{
|
||||
throw new QueryBusinessObjectNotExistException($"The query object {typeof(TEntity).Name} does not exist , or was deleted by someone else, or an incorrect parameter query caused");
|
||||
}
|
||||
else
|
||||
{
|
||||
return (TEntity)businessStruct;
|
||||
}
|
||||
}
|
||||
|
||||
[DoesNotReturn]
|
||||
public static TEntity IfNullThrowConvertException<TEntity>(this TEntity businessObject) where TEntity : class
|
||||
{
|
||||
if (businessObject == null)
|
||||
{
|
||||
throw new QueryBusinessObjectNotExistException($" Can not Convert to {typeof(TEntity).Name} Type, Please check parameter");
|
||||
}
|
||||
else
|
||||
{
|
||||
return businessObject!;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class QueryBusinessObjectNotExistException : Exception
|
||||
{
|
||||
|
||||
public QueryBusinessObjectNotExistException()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public QueryBusinessObjectNotExistException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ConversionException : Exception
|
||||
{
|
||||
public ConversionException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user