zoukankan      html  css  js  c++  java
  • ModelContext模型上下文

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Web;

     

    namespace TeamService.Data

    {

        public class ModelContextStatus

        {

            public const int DISABLED = 0x0000;

            public const int NORMAL = 0x0001;

            public const int DELETED = 0x0004;

        }

        /// <summary>

        /// EntityContext class provides unified access to EF entities

        /// </summary>

        public class ModelContext

        {

            public const int STATUS_DISABLED = ModelContextStatus.DISABLED;

            public const int STATUS_NORMAL = ModelContextStatus.NORMAL;

            public const int STATUS_DELETED = ModelContextStatus.DELETED;

            public const int REMOTE_SERVER = 0;

            public const int LOCAL_SERVER = 1;

     

            private static ModelContainer modelContext = null;

     

     

            /// <summary>

            /// Return current entity framework context, if the connection has not open

            /// yet, it will create the connection to database.

            /// </summary>

            public static ModelContainer Container

            {

                get

                {

                    if (modelContext == null)

                    {

                        modelContext = new ModelContainer();

                      

                        if (modelContext.Connection.State != System.Data.ConnectionState.Open)

                        {

                            modelContext.Connection.Open();

                        }

                    }

                    return modelContext;

                }

            }

        }

    }

  • 相关阅读:
    Cookie数据的编码及解码
    删除单链表节点,时间复杂度为O(1)
    匹配URL
    C#文本框允许使用ctrl+A
    实现统计一个字符串所含的不同字符的总数
    调用win32 api 函数SendMessage() 实现消息直接调用
    关于C++的const对象
    从一个文本文件中找出使用频率最高的五个字符
    C++基础中的基础(深拷贝与浅拷贝)
    python+Django CRM客户关系管理系统开发(十)--左右移动选择框功能开发
  • 原文地址:https://www.cnblogs.com/quietwalk/p/2136033.html
Copyright © 2011-2022 走看看