Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DynamicSql"/> class.
        /// </summary>
        /// <param name="configScope">The config scope.</param>
        /// <param name="statement">The statement.</param>
        internal DynamicSql(ConfigurationScope configScope, IStatement statement)
        {
            _statement = statement;

            _usePositionalParameters = configScope.DataSource.DbProvider.UsePositionalParameters;
            _dataExchangeFactory = configScope.DataExchangeFactory;
        }
Beispiel #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="statement">The statement.</param>
        /// <param name="sqlStatement"></param>
        /// <param name="scope"></param>
        public ProcedureSql(IScope scope, string sqlStatement, IStatement statement)
        {
            _sqlStatement = sqlStatement;
            _statement = statement;

            _dataExchangeFactory = scope.DataExchangeFactory;
        }
 public SqlMapper(IObjectFactory objectFactory, IBatisNet.Common.Utilities.Objects.Members.AccessorFactory accessorFactory)
 {
     this._objectFactory       = objectFactory;
     this._accessorFactory     = accessorFactory;
     this._dataExchangeFactory = new IBatisNet.DataMapper.DataExchange.DataExchangeFactory(this._typeHandlerFactory, this._objectFactory, accessorFactory);
     this._id           = HashCodeProvider.GetIdentityHashCode(this).ToString();
     this._sessionStore = SessionStoreFactory.GetSessionStore(this._id);
 }
Beispiel #4
0
 public RequestScope(IBatisNet.DataMapper.DataExchange.DataExchangeFactory dataExchangeFactory, ISqlMapSession session, IStatement statement)
 {
     this._statement           = statement;
     this._parameterMap        = statement.ParameterMap;
     this._session             = session;
     this._dataExchangeFactory = dataExchangeFactory;
     this._id = GetNextId();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleDynamicSql"/> class.
        /// </summary>
        /// <param name="scope">The scope.</param>
        /// <param name="sqlStatement">The SQL statement.</param>
        /// <param name="statement">The statement.</param>
        internal SimpleDynamicSql(IScope scope,
			string sqlStatement, 
			IStatement statement)
        {
            _simpleSqlStatement = sqlStatement;
            _statement = statement;

            _dataExchangeFactory = scope.DataExchangeFactory;
        }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RequestScope"/> class.
        /// </summary>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="session">The session.</param>
        /// <param name="statement">The statement</param>
        public RequestScope(
            DataExchangeFactory dataExchangeFactory,
            ISqlMapSession session,
            IStatement statement
            )
        {
            _errorContext = new ErrorContext();

            _statement = statement;
            _parameterMap = statement.ParameterMap;
            _session = session;
            _dataExchangeFactory = dataExchangeFactory;
            _id = GetNextId();
        }
Beispiel #7
0
 /// <summary>
 /// Do not use direclty, only for serialization.
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public ParameterMap(DataExchangeFactory dataExchangeFactory)
 {
     _dataExchangeFactory = dataExchangeFactory;
 }
Beispiel #8
0
 /// <summary>
 /// Cosntructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public PrimitiveDataExchange(DataExchangeFactory dataExchangeFactory) : base(dataExchangeFactory)
 {
 }
 /// <summary>
 /// Cosntructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public ListDataExchange(DataExchangeFactory dataExchangeFactory)
     : base(dataExchangeFactory)
 {
 }
        /// <summary>
        /// Builds a <see cref="ResultPropertyCollection"/> for an <see cref="AutoResultMap"/>.
        /// </summary>
        /// <param name="dataExchangeFactory">The data exchange factory.</param>
        /// <param name="reader">The reader.</param>
        /// <param name="resultObject">The result object.</param>
        public static ResultPropertyCollection Build(DataExchangeFactory dataExchangeFactory,
		                        IDataReader reader,
			                    ref object resultObject)
        {
            Type targetType = resultObject.GetType();
            ResultPropertyCollection properties = new ResultPropertyCollection();

            try
            {
                // Get all PropertyInfo from the resultObject properties
                ReflectionInfo reflectionInfo = ReflectionInfo.GetInstance(targetType);
                string[] membersName = reflectionInfo.GetWriteableMemberNames();

                Hashtable propertyMap = new Hashtable();
                int length = membersName.Length;
                for (int i = 0; i < length; i++)
                {
                    ISetAccessorFactory setAccessorFactory = dataExchangeFactory.AccessorFactory.SetAccessorFactory;
                    ISetAccessor setAccessor = setAccessorFactory.CreateSetAccessor(targetType, membersName[i]);
                    propertyMap.Add(membersName[i], setAccessor);
                }

                // Get all column Name from the reader
                // and build a resultMap from with the help of the PropertyInfo[].
                DataTable dataColumn = reader.GetSchemaTable();
                int count = dataColumn.Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    string columnName = dataColumn.Rows[i][0].ToString();
                    ISetAccessor matchedSetAccessor = propertyMap[columnName] as ISetAccessor;

                    ResultProperty property = new ResultProperty();
                    property.ColumnName = columnName;
                    property.ColumnIndex = i;

                    if (resultObject is Hashtable)
                    {
                        property.PropertyName = columnName;
                        properties.Add(property);
                    }

                    Type propertyType = null;

                    if (matchedSetAccessor == null)
                    {
                        try
                        {
                            propertyType = ObjectProbe.GetMemberTypeForSetter(resultObject, columnName);
                        }
                        catch
                        {
                            _logger.Error("The column [" + columnName + "] could not be auto mapped to a property on [" + resultObject.ToString() + "]");
                        }
                    }
                    else
                    {
                        propertyType = matchedSetAccessor.MemberType;
                    }

                    if (propertyType != null || matchedSetAccessor != null)
                    {
                        property.PropertyName = (matchedSetAccessor != null ? matchedSetAccessor.Name : columnName);
                        if (matchedSetAccessor != null)
                        {
                            property.Initialize(dataExchangeFactory.TypeHandlerFactory, matchedSetAccessor);
                        }
                        else
                        {
                            property.TypeHandler = dataExchangeFactory.TypeHandlerFactory.GetTypeHandler(propertyType);
                        }

                        property.PropertyStrategy = PropertyStrategyFactory.Get(property);
                        properties.Add(property);
                    }
                }
            }
            catch (Exception e)
            {
                throw new DataMapperException("Error automapping columns. Cause: " + e.Message, e);
            }

            return properties;
        }
Beispiel #11
0
 public ComplexDataExchange(DataExchangeFactory dataExchangeFactory) : base(dataExchangeFactory)
 {
 }
Beispiel #12
0
 /// <summary>
 /// Cosntructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public ListDataExchange(DataExchangeFactory dataExchangeFactory) : base(dataExchangeFactory)
 {
 }
 /// <summary>
 /// Cosntructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 /// <param name="parameterClass"></param>
 public DotNetObjectDataExchange(Type parameterClass, DataExchangeFactory dataExchangeFactory)
     : base(dataExchangeFactory)
 {
     _parameterClass = parameterClass;
 }
 /// <summary>
 /// Cosntructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 /// <param name="parameterClass"></param>
 public DotNetObjectDataExchange(Type parameterClass, DataExchangeFactory dataExchangeFactory)
     : base(dataExchangeFactory)
 {
     _parameterClass = parameterClass;
 }
 /// <summary>
 /// Cosntructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public ComplexDataExchange(DataExchangeFactory dataExchangeFactory)
     : base(dataExchangeFactory)
 {
 }
 /// <summary>
 /// Cosntructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public DictionaryDataExchange(DataExchangeFactory dataExchangeFactory)
     : base(dataExchangeFactory)
 {
 }
 /// <summary>
 /// Cosntructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public PrimitiveDataExchange(DataExchangeFactory dataExchangeFactory)
     : base(dataExchangeFactory)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public BaseDataExchange(DataExchangeFactory dataExchangeFactory)
 {
     _dataExchangeFactory = dataExchangeFactory;
 }
Beispiel #19
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="statement">The statement.</param>
        /// <param name="scope"></param>
        public StaticSql(IScope scope, IStatement statement)
        {
            _statement = statement;

            _dataExchangeFactory = scope.DataExchangeFactory;
        }
Beispiel #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultMap"/> class.
        /// </summary>
        /// <param name="configScope">The config scope.</param>
        /// <param name="className">The output class name of the resultMap.</param>
        /// <param name="extendMap">The extend result map bame.</param>
        /// <param name="id">Identifier used to identify the resultMap amongst the others.</param>
        /// <param name="groupBy">The groupBy properties</param>
        public ResultMap(ConfigurationScope configScope, string id, string className, string extendMap, string groupBy)
        {
            _nullResultMap = new NullResultMap();

            _dataExchangeFactory = configScope.DataExchangeFactory;
            _sqlMapNameSpace = configScope.SqlMapNamespace;
            if ((id == null) || (id.Length < 1))
            {
                 throw new ArgumentNullException("The id attribute is mandatory in a ResultMap tag.");
            }
            _id = configScope.ApplyNamespace(id);
            if ((className == null) || (className.Length < 1))
            {
                throw new ArgumentNullException("The class attribute is mandatory in the ResultMap tag id:"+_id);
            }
            _className = className;
            _extendMap = extendMap;
             if (groupBy != null && groupBy.Length>0)
             {
                 string[] groupByProperties = groupBy.Split(',');
                 for (int i = 0; i < groupByProperties.Length; i++)
                 {
                     string memberName = groupByProperties[i].Trim();
                     _groupByPropertyNames.Add(memberName);
                 }
             }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dataExchangeFactory"></param>
 public BaseDataExchange(DataExchangeFactory dataExchangeFactory)
 {
     _dataExchangeFactory = dataExchangeFactory;
 }