using System;
namespace WalkingTec.Mvvm.Core
{
public enum DBOperationEnum { Default, Read, Write }
///
/// 标记Controller或Action使用固定的连接字符串,不受其他设定控制
///
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public class FixConnectionAttribute : Attribute
{
///
/// 连接字符串名称
///
public string CsName { get; set; }
public DBTypeEnum? DbType { get; set; }
///
/// 操作类型,读或写
///
public DBOperationEnum Operation { get; set; }
///
/// 新建固定连接字符串标记
///
/// Operation
/// the key of the ConnectionString in appsettings
public FixConnectionAttribute(DBOperationEnum Operation = DBOperationEnum.Default, string CsName = "")
{
this.CsName = CsName;
this.Operation = Operation;
this.DbType = null;
}
///
/// 操作类型,读或写
///
/// the database type, if t is Default, the value in appsettings will be used
/// Operation
/// the key of the ConnectionString in appsettings
public FixConnectionAttribute(DBTypeEnum DbType, DBOperationEnum Operation = DBOperationEnum.Default, string CsName = "")
{
this.CsName = CsName;
this.Operation = Operation;
this.DbType = DbType;
}
}
}