connectionattribute.cs

来自「smark.data是基于C#开发的轻量级数据访问组件。 提供以下功能封: 」· CS 代码 · 共 51 行

CS
51
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace Smark.Data.Mappings
{
    [AttributeUsage(AttributeTargets.Class| AttributeTargets.Interface)]
    public class ConnectionAttribute:Attribute
    {
        public ConnectionAttribute(ConnectionType type)
        {
            Type = type;
        }
        public ConnectionType Type
        {
            get;
            set;
        }
        public IConnectinContext GetContext()
        {
            switch (Type)
            {
                case ConnectionType.Context:
                    return DBContext.Context;
                case ConnectionType.Context1:
                    return DBContext.Context1;
                case ConnectionType.Context2:
                    return DBContext.Context2;
                case ConnectionType.Context3:
                    return DBContext.Context3;
                case ConnectionType.Context4:
                    return DBContext.Context4;
                case ConnectionType.Context5:
                    return DBContext.Context5;

            }
            return DBContext.Context;
        }
    }
    public enum ConnectionType
    {
       Context,
       Context1,
       Context2,
       Context3,
       Context4,
       Context5

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?