public override object LoadAliasJoinTableData(DataContext context, IDataReader dataReader, QueryState queryState, string aliasName)
        {
            var item          = Activator.CreateInstance(ObjectType);
            var nodataSetNull = queryState?.CheckNoDataSetNull(aliasName) ?? false;
            var hasData       = false;

            foreach (var field in _fieldList)
            {
                var name = string.Format("{0}_{1}", aliasName, field.Name);
                if (queryState == null)
                {
                    var obj   = dataReader [name];
                    var value = field.ToProperty(obj);
                    if (!Equals(value, null))
                    {
                        field.Handler.Set(item, value);
                    }
                }
                else if (queryState.CheckSelectField(name))
                {
                    var obj   = dataReader [name];
                    var value = field.ToProperty(obj);
                    if (!Equals(value, null))
                    {
                        field.Handler.Set(item, value);
                        hasData = true;
                    }
                }
            }
            if (!hasData && nodataSetNull)
            {
                return(null);
            }
            return(item);
        }
Beispiel #2
0
        public virtual object LoadAliasJoinTableData(DataContext context, IDataReader dataReader, QueryState queryState,
                                                     string aliasName)
        {
            var item          = Activator.CreateInstance(ObjectType);
            var nodataSetNull = queryState?.CheckNoDataSetNull(aliasName) ?? false;
            var hasData       = false;

            foreach (var field in _fieldList)
            {
                if (field == null)
                {
                    continue;
                }
                var name = $"{aliasName}_{field.Name}";
                if (queryState == null)
                {
                    var obj   = dataReader[name];
                    var value = field.ToProperty(obj);
                    if (!Equals(value, null))
                    {
                        field.Handler.Set(item, value);
                    }
                }
                else if (queryState.CheckSelectField(name))
                {
                    var obj   = dataReader[name];
                    var value = field.ToProperty(obj);
                    if (!Equals(value, null))
                    {
                        hasData = true;
                        field.Handler.Set(item, value);
                    }
                }
            }

            if (_collectionRelationFields.Count > 0)
            {
                foreach (var mapping in _collectionRelationFields)
                {
                    mapping.Handler.Set(item, mapping.ToProperty(context, item, false));
                }
            }

            if (!hasData && nodataSetNull)
            {
                return(null);
            }

            if (IsDataEntity && item is DataEntity entity)
            {
                entity.SetContext(context);
            }

            return(item);
        }
Beispiel #3
0
        public virtual object LoadAliasJoinTableData(DataContext context, IDataReader datareader, QueryState queryState, string aliasName)
        {
            object item          = Activator.CreateInstance(ObjectType);
            bool   nodataSetNull = queryState != null?queryState.CheckNoDataSetNull(aliasName) : false;

            bool hasData = false;

            foreach (DataFieldMapping field in this._fieldList)
            {
                if (field == null)
                {
                    continue;
                }
                string name = string.Format("{0}_{1}", aliasName, field.Name);
                if (queryState == null)
                {
                    object obj   = datareader[name];
                    object value = field.ToProperty(obj);
                    if (!Object.Equals(value, null))
                    {
                        field.Handler.Set(item, value);
                    }
                }
                else if (queryState.CheckSelectField(name))
                {
                    object obj   = datareader[name];
                    object value = field.ToProperty(obj);
                    if (!Object.Equals(value, null))
                    {
                        hasData = true;
                        field.Handler.Set(item, value);
                    }
                }
            }
            if (_collectionRelationFields.Count > 0)
            {
                foreach (CollectionRelationFieldMapping mapping in _collectionRelationFields)
                {
                    mapping.Handler.Set(item, mapping.ToProperty(context, item, false));
                }
            }
            if (!hasData && nodataSetNull)
            {
                return(null);
            }
            if (_isDataEntity)
            {
                DataEntity entity = item as DataEntity;
                entity.SetContext(context);
            }
            return(item);
        }
Beispiel #4
0
        public override object LoadAliasJoinTableData(DataContext context, IDataReader datareader, QueryState queryState, string aliasName)
        {
            object[] args          = new object[this._fieldList.Count];
            int      index         = 0;
            bool     nodataSetNull = queryState != null?queryState.CheckNoDataSetNull(aliasName) : false;

            bool hasData = false;

            foreach (DynamicFieldMapping field in this._fieldList)
            {
                string name = string.Format("{0}_{1}", aliasName, field.Name);
                if (queryState == null)
                {
                    object obj   = datareader[name];
                    object value = field.ToProperty(obj);
                    args[index] = value;
                }
                else if (queryState.CheckSelectField(name))
                {
                    object obj   = datareader[name];
                    object value = field.ToProperty(obj);
                    if (!Object.Equals(value, null))
                    {
                        hasData = true;
                    }
                    args[index] = value;
                }
                index++;
            }
            if (!hasData && nodataSetNull)
            {
                return(null);
            }
            object item = Activator.CreateInstance(ObjectType, args);

            return(item);
        }
        public override object LoadAliasJoinTableData(DataContext context, IDataReader datareader, QueryState queryState, string aliasName)
        {
            object item          = Activator.CreateInstance(ObjectType);
            bool   nodataSetNull = queryState != null?queryState.CheckNoDataSetNull(aliasName) : false;

            bool hasData = false;

            foreach (DataFieldMapping field in this._fieldList)
            {
                string name = string.Format("{0}_{1}", aliasName, field.Name);
                if (queryState == null)
                {
                    object obj   = datareader [name];
                    object value = field.ToProperty(obj);
                    if (!Object.Equals(value, null))
                    {
                        field.Handler.Set(item, value);
                    }
                }
                else if (queryState.CheckSelectField(name))
                {
                    object obj   = datareader [name];
                    object value = field.ToProperty(obj);
                    if (!Object.Equals(value, null))
                    {
                        field.Handler.Set(item, value);
                        hasData = true;
                    }
                }
            }
            if (!hasData && nodataSetNull)
            {
                return(null);
            }
            return(item);
        }