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); }
public override object LoadData(DataContext context, IDataReader datareader, object state) { object item = Activator.CreateInstance(ObjectType); QueryState queryState = state as QueryState; foreach (DataFieldMapping field in this._fieldList) { if (queryState == null) { object obj = datareader[field.Name]; object value = field.ToProperty(obj); if (!Object.Equals(value, null)) { field.Handler.Set(item, value); } } else if (queryState.CheckSelectField(field.Name)) { object obj = datareader[field.Name]; object value = field.ToProperty(obj); if (!Object.Equals(value, null)) { field.Handler.Set(item, value); } } } return(item); }
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); }
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); }
public object ToProperty(DataContext context, IDataReader datareader, QueryState queryState, string fieldPath) { if (!queryState.GetJoinData(fieldPath, out object value)) { string aliasName = queryState.GetAliasName(fieldPath); foreach (DataFieldInfo info in this.relateInfos) { string name = string.Format("{0}_{1}", aliasName, info.FieldName); if (queryState.CheckSelectField(aliasName)) { object obj = datareader[name]; if (Object.Equals(obj, DBNull.Value) || Object.Equals(obj, null)) { queryState.SetJoinData(fieldPath, null); return(null); } } else { queryState.SetJoinData(fieldPath, null); return(null); } } if (queryState.CheckSelectField(aliasName)) { //object item = Activator.CreateInstance(this.RelateMapping.ObjectType); //queryState.SetJoinData(fieldPath, item); //this.relateEntityMapping.LoadJoinTableData(context, datareader, item, queryState, fieldPath); //value = item; value = this.relateEntityMapping.LoadJoinTableData(context, datareader, queryState, fieldPath); } else { queryState.SetJoinData(fieldPath, null); return(null); } } return(value); }
public object LoadAliasJoinTableData(DataContext context, IDataReader datareader, QueryState queryState, string aliasName) { string fieldname = string.Format("{0}_{1}", aliasName, name); object value = null; if (queryState == null) { value = dataDefine.LoadData(context, datareader, name, queryState); } else if (queryState.CheckSelectField(name)) { value = dataDefine.LoadData(context, datareader, name, queryState); } return(value); }
public override object LoadData(DataContext context, IDataReader datareader, object state) { QueryState queryState = state as QueryState; object value = null; if (queryState == null) { value = dataDefine.LoadData(context, datareader, name, state); } else if (queryState.CheckSelectField(name)) { value = dataDefine.LoadData(context, datareader, name, state); } return(value); }
public virtual object LoadJoinTableData(DataContext context, IDataReader dataReader, QueryState queryState, string fieldPath) { var item = Activator.CreateInstance(ObjectType); queryState.SetJoinData(fieldPath, item); var aliasName = queryState.GetAliasName(fieldPath); foreach (var field in _fieldList) { var name = $"{aliasName}_{field.Name}"; if (queryState.CheckSelectField(name)) { var obj = dataReader[name]; var value = field.ToProperty(obj); if (!Equals(value, null)) { field.Handler.Set(item, value); } } } if (_collectionRelationFields.Count > 0) { foreach (var mapping in _collectionRelationFields) { mapping.Handler.Set(item, mapping.ToProperty(context, item, true)); } } foreach (var mapping in _singleRelationFields) { var path = $"{fieldPath}.{mapping.FieldName}"; var value = mapping.ToProperty(context, dataReader, queryState, path); if (!Equals(value, null)) { mapping.Handler.Set(item, value); } } if (IsDataEntity && item is DataEntity entity) { entity.SetContext(context); } return(item); }
public override object LoadData(DataContext context, IDataReader datareader, object state) { QueryState queryState = state as QueryState; if (this._singleRelationFields.Count > 0) { queryState.InitialJoinData(); return(LoadJoinTableData(context, datareader, queryState, string.Empty)); } object item = Activator.CreateInstance(ObjectType); foreach (DataFieldMapping field in this._fieldList) { if (queryState == null) { object obj = datareader[field.Name]; object value = field.ToProperty(obj); if (!Object.Equals(value, null)) { field.Handler.Set(item, value); } } else if (queryState.CheckSelectField(field.Name)) { object obj = datareader[field.Name]; object value = field.ToProperty(obj); if (!Object.Equals(value, null)) { field.Handler.Set(item, value); } } } if (_collectionRelationFields.Count > 0) { foreach (CollectionRelationFieldMapping mapping in _collectionRelationFields) { mapping.Handler.Set(item, mapping.ToProperty(context, item, true)); } } if (_isDataEntity) { DataEntity entity = item as DataEntity; entity.SetContext(context); } return(item); }
//public virtual void LoadJoinTableData(DataContext context, IDataReader datareader, object item, QueryState queryState, string fieldPath) //{ // string aliasName = queryState.GetAliasName(fieldPath); // foreach (DataFieldMapping field in this._fieldList) { // string name = string.Format("{0}_{1}", aliasName, field.Name); // if (queryState.CheckSelectField(name)) { // object obj = datareader[name]; // object value = field.ToProperty(obj); // if (!Object.Equals(value, null)) { // field.Handler.Set(item, value); // } // } // } // if (_collectionRelationFields.Count > 0) { // foreach (CollectionRelationFieldMapping mapping in _collectionRelationFields) { // mapping.Handler.Set(item, mapping.ToProperty(context, item, true)); // } // } // foreach (SingleRelationFieldMapping mapping in _singleRelationFields) { // string fpath = string.Format("{0}.{1}", fieldPath, mapping.FieldName); // object value = mapping.ToProperty(context, datareader, queryState, fpath); // if (!Object.Equals(value, null)) { // mapping.Handler.Set(item, value); // } // } // if (item is DataEntity entity) { // entity.SetContext(context); // entity.LoadDataComplete(); // } //} public virtual object LoadJoinTableData(DataContext context, IDataReader datareader, QueryState queryState, string fieldPath) { object item = Activator.CreateInstance(this.ObjectType); queryState.SetJoinData(fieldPath, item); string aliasName = queryState.GetAliasName(fieldPath); foreach (DataFieldMapping field in this._fieldList) { string name = string.Format("{0}_{1}", aliasName, field.Name); if (queryState.CheckSelectField(name)) { object obj = datareader[name]; object value = field.ToProperty(obj); if (!Object.Equals(value, null)) { field.Handler.Set(item, value); } } } if (_collectionRelationFields.Count > 0) { foreach (CollectionRelationFieldMapping mapping in _collectionRelationFields) { mapping.Handler.Set(item, mapping.ToProperty(context, item, true)); } } foreach (SingleRelationFieldMapping mapping in _singleRelationFields) { string fpath = string.Format("{0}.{1}", fieldPath, mapping.FieldName); object value = mapping.ToProperty(context, datareader, queryState, fpath); if (!Object.Equals(value, null)) { mapping.Handler.Set(item, value); } } if (_isDataEntity) { DataEntity entity = item as DataEntity; entity.SetContext(context); } return(item); }
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); }