本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: GetContext
private IContext GetContext()
{
IContext context = new Context(mapPath);
if (connectionString != "")
{
context.SetConnectionString(connectionString);
}
context.AssemblyManager.RegisterAssembly(domain);
return context;
}
示例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;
}