// =============================================================================== // Setupper // ======== protected void SetupInsertPropertyTypes(string[] propertyNames) { ArrayList types = new ArrayList(); for (int i = 0; i < propertyNames.Length; ++i) { IPropertyType pt = BeanMetaData.GetPropertyType(propertyNames[i]); if (pt.IsPrimaryKey && !BeanMetaData.IdentifierGenerator.IsSelfGenerate) { continue; } types.Add(pt); } propertyTypes = (IPropertyType[])types.ToArray(typeof(IPropertyType)); }
protected void SetupUpdatePropertyTypes(string[] propertyNames) { ArrayList types = new ArrayList(); for (int i = 0; i < propertyNames.Length; ++i) { IPropertyType pt = BeanMetaData.GetPropertyType(propertyNames[i]); if (pt.IsPrimaryKey) { continue; } types.Add(pt); } propertyTypes = (IPropertyType[])types.ToArray(typeof(IPropertyType)); }
protected void Handle(IDataReader dataReader, System.Collections.IList list) { // Lazy initialization because if the result is zero, the resources are unused. System.Collections.IList columnNames = null; IColumnMetaData[] columns = null; IDictionary <String, IDictionary <String, IPropertyType> > relationPropertyCache = null; RelationRowCache relRowCache = null; int relSize = BeanMetaData.RelationPropertyTypeSize; bool hasCB = HasConditionBean(); bool skipRelationLoop; { bool emptyRelation = IsSelectedForeignInfoEmpty(); bool hasOSC = HasOutsideSqlContext(); bool specifiedOutsideSql = IsSpecifiedOutsideSql(); // If it has condition-bean that has no relation to get // or it has outside-sql context that is specified-outside-sql, // they are unnecessary to do relation loop! skipRelationLoop = (hasCB && emptyRelation) || (hasOSC && specifiedOutsideSql); } bool canCache = hasCB && CanRelationMappingCache(); Map <String, int?> selectIndexMap = GetSelectIndexMap(); while (dataReader.Read()) { if (columnNames == null) { columnNames = CreateColumnNames(dataReader.GetSchemaTable()); } if (columns == null) { columns = CreateColumnMetaData(columnNames); } // Create row instance of base table by row property cache. Object row = CreateRow(dataReader, columns); if (skipRelationLoop) { PostCreateRow(row, BeanMetaData); list.Add(row); continue; } if (relationPropertyCache == null) { relationPropertyCache = CreateRelationPropertyCache(columnNames); } if (relRowCache == null) { relRowCache = new RelationRowCache(relSize); } for (int i = 0; i < relSize; ++i) { IRelationPropertyType rpt = BeanMetaData.GetRelationPropertyType(i); if (rpt == null) { continue; } // Do only selected foreign property for performance if condition-bean exists. if (hasCB && !HasSelectedForeignInfo(BuildRelationNoSuffix(rpt))) { continue; } Object relationRow = null; System.Collections.Hashtable relKeyValues = new System.Collections.Hashtable(); RelationKey relKey = CreateRelationKey(dataReader, rpt, columnNames, relKeyValues, selectIndexMap); if (relKey != null) { relationRow = GetCachedRelationRow(relRowCache, i, relKey, canCache); if (relationRow == null) { relationRow = CreateRelationRow(dataReader, rpt, columnNames, relKeyValues, relationPropertyCache); if (relationRow != null) { AddRelationRowCache(relRowCache, i, relKey, relationRow, canCache); PostCreateRow(relationRow, rpt.BeanMetaData); } } } if (relationRow != null) { PropertyInfo pi = rpt.PropertyInfo; pi.SetValue(row, relationRow, null); } } PostCreateRow(row, BeanMetaData); list.Add(row); } }