当前位置: 首页>>代码示例>>C#>>正文


C# Context.SetConnectionString方法代码示例

本文整理汇总了C#中Context.SetConnectionString方法的典型用法代码示例。如果您正苦于以下问题:C# Context.SetConnectionString方法的具体用法?C# Context.SetConnectionString怎么用?C# Context.SetConnectionString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Context的用法示例。


在下文中一共展示了Context.SetConnectionString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetContext

        public static IContext GetContext()
        {
            //Get a reference to the Northwind.Domain assembly containing the
            //npersist xml mapping file as an embedded resource.
            //Use any of the classes in the domain to obtain a reference
            //to the assembly.
            Assembly asm = Assembly.GetAssembly(typeof(Employee));

            //Create an instance of the Context, passing the assembly
            //and the name of the embedded xml file to the contructor
            IContext context = new Context(asm, MapResourceName);

            //Set the connection string to our database
            context.SetConnectionString(ConnectionString);

            //return the new context
            return context;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:18,代码来源:ContextFactory.cs

示例2: GetContext

        private IContext GetContext()
        {
            //Create a context object passing the assembly
            //containing the domain model to the constructor
            IContext context = new Context(this.GetType().Assembly);

            //Set the connection string to the database
            context.SetConnectionString("SERVER=(local);UID=sa;PWD=;DATABASE=HelloWorld");

            //return the new context
            return context;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:12,代码来源:Form1.cs

示例3: GetContext

 private IContext GetContext()
 {
     Assembly asm = typeof(Employee).Assembly;
     IContext context = new Context(asm, "Puzzle.NPersist.Samples.Northwind.Domain.Puzzle.NPersist.Samples.Northwind.Domain.npersist");
     context.SetConnectionString("SERVER=(local);DATABASE=Northwind;integrated security=true;");
     return context;
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:7,代码来源:SimpleLinq2NPathUnitTest.cs

示例4: GetContext

        private IContext GetContext()
        {
            IContext context = new Context(mapPath);

            if (connectionString != "")
            {
                context.SetConnectionString(connectionString);
            }

            context.AssemblyManager.RegisterAssembly(domain);
            return context;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:12,代码来源:Form1.cs

示例5: GetContext

        public IContext GetContext(string domainKey)
        {
            string useMapPath = this.mapPath;
            string useConnectionString = this.connectionString;

            if (domainKey != null)
            {
                if (domainKey.Length > 0)
                {
            #if NET2
                    useMapPath = System.Configuration.ConfigurationManager.AppSettings["MapPathForKey-" + domainKey];
                    useConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionStringForKey-" + domainKey];
                    string domainPath = System.Configuration.ConfigurationManager.AppSettings["DomainAssemblyForKey-" + domainKey];
            #else
                    useMapPath = System.Configuration.ConfigurationSettings.AppSettings["MapPathForKey-" + domainKey];
                    useConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionStringForKey-" + domainKey];
                    string domainPath = System.Configuration.ConfigurationSettings.AppSettings["DomainAssemblyForKey-" + domainKey];
            #endif

                    if (domainPath != null && domainPath.Length > 0)
                    {
                        Assembly asm = Assembly.Load(domainPath);
                    }
                    else
                    {
                        throw new NPathException("Could not find Domain Assembly for key '" + domainKey + "' in application configuration!");
                    }

                }
            }
            IContext ctx = new Context(useMapPath);
            if (useConnectionString != "")
            {
                ctx.SetConnectionString(useConnectionString);
            }
            return ctx;
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:37,代码来源:ContextFactory.cs


注:本文中的Context.SetConnectionString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。