添加项目文件。
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace IM.ASPNETCore
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class
|
||||
| AttributeTargets.Method, AllowMultiple = false, Inherited = true
|
||||
)]
|
||||
public class UnitOfWorkAttribute : Attribute
|
||||
{
|
||||
public Type[] DbContextTypes { get; private set; }
|
||||
|
||||
public UnitOfWorkAttribute(params Type[] dbContextTypes)
|
||||
{
|
||||
this.DbContextTypes = dbContextTypes;
|
||||
foreach (var type in dbContextTypes)
|
||||
{
|
||||
if (!typeof(DbContext).IsAssignableFrom(type))
|
||||
{
|
||||
throw new ArgumentException($"{type} must inherit from DbContext");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user