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;

                }

            }

        }

    }

  • 相关阅读:
    GoLang设计模式15 策略模式
    GoLang设计模式18 适配器模式
    GoLang设计模式14 状态模式
    GoLang设计模式12 空对象模式
    GoLang设计模式19 桥接模式
    GoLang设计模式17 访客模式
    GoLang设计模式13 观察者模式
    GoLang设计模式16 模板方法模式
    Papervision3D材质
    Papervision3D基本原理
  • 原文地址:https://www.cnblogs.com/quietwalk/p/2136033.html
Copyright © 2011-2022 走看看