public void TestConfigureRelativePathViaBuilder() { DomSqlMapBuilder builder = new DomSqlMapBuilder(); NameValueCollection properties = new NameValueCollection(); properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test"); properties.Add("nullableInt", "int"); builder.Properties = properties; ISqlMapper mapper = builder.Configure(_fileName); Assert.IsNotNull(mapper); }
protected override object InternalCreate(CreationContext context) { String fileName = (String) Model.ExtendedProperties[IBatisNetFacility.MAPPER_CONFIG_FILE]; bool isEmbedded = (bool) Model.ExtendedProperties[IBatisNetFacility.MAPPER_CONFIG_EMBEDDED]; String connectionString = (String) Model.ExtendedProperties[IBatisNetFacility.MAPPER_CONFIG_CONNECTION_STRING]; DomSqlMapBuilder domSqlMapBuilder = new DomSqlMapBuilder(); ISqlMapper sqlMapper; if (isEmbedded) { XmlDocument sqlMapConfig = Resources.GetEmbeddedResourceAsXmlDocument(fileName); sqlMapper = domSqlMapBuilder.Configure(sqlMapConfig); } else { sqlMapper = domSqlMapBuilder.Configure(fileName); } if (connectionString != null && connectionString.Length > 0) { sqlMapper.DataSource.ConnectionString = connectionString; } if (sqlMapper != null) { return sqlMapper; } else { throw new FacilityException(string.Format("The IBatisNetIntegration Facility was unable to successfully configure SqlMapper ID [{0}] with File [{1}] that was set to Embedded [{2}].", Model.Name, Model.ExtendedProperties[IBatisNetFacility.MAPPER_CONFIG_FILE].ToString(), Model.ExtendedProperties[IBatisNetFacility.MAPPER_CONFIG_EMBEDDED].ToString())); } }
/// <summary> /// 模块加载处理。 /// </summary> /// <param name="builder">Autofac容器</param> protected override void Load(ContainerBuilder builder) { // 注册IBatisNet。 builder.Register(c => { var sqlMapBuilder = new DomSqlMapBuilder(); return sqlMapBuilder.Configure(HttpContext.Current.Server.MapPath("~/App_Data/IBatisNet/MSSQL/SqlConfig-Reader.xml")); }) .As<ISqlMapper>() .SingleInstance(); builder.Register(c => new SqlMapperManager(c.Resolve<ISqlMapper>())) .SingleInstance(); builder.Register(c => new Persistence {SqlMapperManager = c.Resolve<SqlMapperManager>()}) .InstancePerLifetimeScope(); // 注册基于SQL Server的DynamicQueryProvider builder.Register(c => new IBatisNetMSSQLDynamicQueryProvider(c.Resolve<ISqlMapper>())) .As<DynamicQueryProvider>() .InstancePerLifetimeScope(); // 注册DynamicQuery builder.Register(c => new DynamicQuery { Provider = c.Resolve<DynamicQueryProvider>() }) .InstancePerLifetimeScope(); }
/// <summary> /// 只在系统启动时调用一次 /// </summary> public static void InitSqlMapper() { var builder = new DomSqlMapBuilder(); var configfileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, CONFIGPATH, FILENAME); _sqlMapper = builder.Configure(configfileName); Console.WriteLine("动态查询模板配置完毕"); }
public ProductService() { DomSqlMapBuilder getdombuilder = new DomSqlMapBuilder(); if(getdombuilder!=null) ProductService._getsqlmapper = getdombuilder.Configure() as SqlMapper; _getsqlManager = Mapper.Instance(); }
public static ISqlMapper Build(string contextName) { DomSqlMapBuilder builder = new DomSqlMapBuilder(); if (contextName.Length > 0) contextName = contextName + "."; Stream stream = new EmbeddedResourceHelper().GetEmbeddedFile(Assembly.GetCallingAssembly(), contextName + "sqlmap.config"); return builder.Configure(stream); }
static CentaPostCacheRW() { try { var builder = new DomSqlMapBuilder(); Mapper = builder.Configure("SqlMap.config") as SqlMapper; } catch (IBatisNet.DataMapper.Exceptions.DataMapperException ex) { throw ex; } }
public CustomerService() { #region Define the Base Map _getDaoManager = ServiceConfig.GetInstance().DaoManager; if (_getDaoManager != null) _getbaseService = _getDaoManager.GetDao(typeof(CustomerMapDao)) as ICustomerDao; #endregion #region Use SqlMaper Style to Soleuv this Connection Problem f**k =--- DomSqlMapBuilder getbuilder = new DomSqlMapBuilder(); if (getbuilder != null) _getsqlmaper = getbuilder.Configure() as SqlMapper; #endregion }
static MyIbatisNet() { if (SqlMap == null) { lock (syncObj) { if (SqlMap == null) { Assembly assembly = Assembly.Load("Test.Respository"); Stream stream = assembly.GetManifestResourceStream("Test.Respository.sqlmap.config"); DomSqlMapBuilder builder = new DomSqlMapBuilder(); SqlMap = builder.Configure(stream); } } } }
/// <summary> /// 初始化Ibatis的SqlMapper /// </summary> public static void InitMapper(string configFilePath = null) { var builder = new DomSqlMapBuilder(); mapper = string.IsNullOrEmpty(configFilePath) ? builder.Configure() : builder.Configure(configFilePath); mapper.SessionStore = new HybridWebThreadSessionStore(mapper.Id); }
protected virtual void SetUpFixture() { //DateTime start = DateTime.Now; DomSqlMapBuilder builder = new DomSqlMapBuilder(); #if dotnet2 NameValueCollection properties = new NameValueCollection(); properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection2, IBatisNet.DataMapper.Test"); properties.Add("nullableInt", "int?"); builder.Properties = properties; string fileName = "sqlmap" + "_" + ConfigurationManager.AppSettings["database"] + "_" + ConfigurationManager.AppSettings["providerType"] + ".config"; #else NameValueCollection properties = new NameValueCollection(); properties.Add("collection2Namespace","IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test"); properties.Add("nullableInt", "int"); builder.Properties = properties; string fileName = "sqlmap" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config"; #endif try { sqlMap = builder.Configure(fileName); } catch (Exception ex) { Exception e = ex; while (e != null) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace.ToString()); e = e.InnerException; } throw; } if (sqlMap.DataSource.DbProvider.Name.IndexOf("PostgreSql") >= 0) { BaseTest.ConvertKey = new KeyConvert(Lower); } else if (sqlMap.DataSource.DbProvider.Name.IndexOf("oracle") >= 0) { BaseTest.ConvertKey = new KeyConvert(Upper); } else { BaseTest.ConvertKey = new KeyConvert(Normal); } // string loadTime = DateTime.Now.Subtract(start).ToString(); // Console.WriteLine("Loading configuration time :"+loadTime); }
/// <summary> /// 配置SQL映射 /// </summary> /// <returns>SQL映射</returns> public static ISqlMapper GetMapper() { DomSqlMapBuilder builder = new DomSqlMapBuilder(); ISqlMapper Map = builder.Configure("Config/sqlmap.config"); return Map; }
public void TestConfigureViaStream() { // embeddedResource = "SqlMap_MSSQL_SqlClient.config, IBatisNet.DataMapper.Test"; #if dotnet2 Assembly assembly = Assembly.Load("IBatisNet.DataMapper.Test"); #else Assembly assembly = Assembly.LoadWithPartialName ("IBatisNet.DataMapper.Test"); #endif Stream stream = assembly.GetManifestResourceStream("IBatisNet.DataMapper.Test.SqlMap_MSSQL_SqlClient.config"); DomSqlMapBuilder builder = new DomSqlMapBuilder(); NameValueCollection properties = new NameValueCollection(); properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test"); properties.Add("nullableInt", "int"); builder.Properties = properties; ISqlMapper mapper = builder.Configure(stream); Assert.IsNotNull(mapper); }
public void TestConfigureAbsolutePathWithFileSuffixViaBuilder() { _fileName = "file://"+Resources.BaseDirectory+Path.DirectorySeparatorChar+_fileName; DomSqlMapBuilder builder = new DomSqlMapBuilder(); NameValueCollection properties = new NameValueCollection(); properties.Add("collection2Namespace", "IBatisNet.DataMapper.Test.Domain.LineItemCollection, IBatisNet.DataMapper.Test"); properties.Add("nullableInt", "int"); builder.Properties = properties; ISqlMapper mapper = builder.Configure(_fileName); Assert.IsNotNull(mapper); }
public void InsertProduct(Product getproduct) { ISqlMapper _getsqlManager = null; DomSqlMapBuilder getdombuilder = new DomSqlMapBuilder(); if (getdombuilder != null) ProductService._getsqlmapper = getdombuilder.Configure() as SqlMapper; _getsqlManager = Mapper.Instance(); if (_getsqlManager!=null) _getsqlManager.Insert("InsertProduct", getproduct); }
/// <summary> /// Init the 'default' SqlMapper defined by the SqlMap.Config file. /// </summary> protected static void InitMapper() { DomSqlMapBuilder builder = new DomSqlMapBuilder(); string config = ConfigurationManager.AppSettings.Get("sqlmapconfig"); _Mapper = builder.Configure(config); }
public void TestProcedure_Delete() { using (var repo = RepositoryContext.GetRepository()) { var id = new DeleteProcedureClass(); var addedcategory = repo.GetAll<Category>(); id.ID = addedcategory[0].ID; var builder = new DomSqlMapBuilder(); var configfileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config", "SqlMap.config"); ISqlMapper mapper = builder.Configure(configfileName); mapper.Delete("DeleteProcedureTest", id); } }