Example #1
0
		internal IndexInfo(Table table, Index index)
		{
			_name = MakeName("IX_", table.Name, index.ColumnIterator);
			_columns = CollectionUtils.Map<Column, string>(
				index.ColumnIterator,
				delegate(Column column) { return column.Name; });
		}
Example #2
0
		private Mapping.Collection CreateList(XmlNode node, string prefix, string path,
			PersistentClass owner, System.Type containingType)
		{
			List list = new List(owner);
			BindCollection(node, list, prefix, path, containingType);
			return list;
		}
 public PrimaryKeyModel(List<Column> pkCols, bool identity, string name, bool clustered)
 {
     PkCols = pkCols;
     Identity = identity;
     Name = name;
     Clustered = clustered;
 }
        public ISlabInfo[] GetSlabInfoByTimeInterval(long aFrom, long aTo)
        {
            try {
                using (var session = NHibernateHelper.OpenSession()) {
                    var entitys = session.CreateCriteria(typeof(SlabInfoEntity))
                    .Add(Restrictions.Between("StartScanTime", aFrom, aTo))
                    .List<SlabInfoEntity>();

                    var results = new List<ISlabInfo>();
                    foreach (var entity in entitys) {
                        results.Add(new SlabInfoImpl {
                            Id = entity.Id,
                            Number = entity.Number,
                            StandartSizeId = entity.StandartSizeId,
                            StartScanTime = entity.StartScanTime,
                            EndScanTime = entity.EndScanTime
                        });
                    }

                    return results.ToArray();
                }
            }
            catch (Exception ex) {
                logger.Error("Ошибка при чтении SlabInfo: " + ex.Message);
                return null;
            }
        }
Example #5
0
 public Mapper(Assembly[] assemblies)
 {
     _assemblies = assemblies;
     _conventions = new List<Convention>(12);
     _hiloInserts = new List<string>(20);
     AppendConventions();
 }
 public override PropertyDescriptorCollection GetProperties()
 {
     if (_properties == null)
     {
         bool hasEntityAttributes = false;
         _properties = base.GetProperties();
         var list = new List<PropertyDescriptor>();
         foreach (PropertyDescriptor descriptor in _properties)
         {
             List<Attribute> attrs = GetEntityMemberAttributes(descriptor).ToList();
             if (_metaDataAttributes.ContainsKey(descriptor.Name))
                 attrs.AddRange(_metaDataAttributes[descriptor.Name]);
             if (attrs.Any())
             {
                 hasEntityAttributes = true;
                 list.Add(new PropertyDescriptorWrapper(descriptor, attrs.ToArray()));
             }
             else
             {
                 list.Add(descriptor);
             }
         }
         if (hasEntityAttributes)
             _properties = new PropertyDescriptorCollection(list.ToArray(), true);
     }
     return _properties;
 }
		private Mapping.Collection CreateList(XmlNode node, string prefix, string path,
			PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			List list = new List(owner);
			BindCollection(node, list, prefix, path, containingType, inheritedMetas);
			return list;
		}
Example #8
0
		private void ProcessIndex(XmlElement indexElement, IDictionary<string, Table> tables)
		{
			var tableName = indexElement.GetAttribute("table");
			var columnNames = CollectionUtils.Map(indexElement.GetAttribute("columns").Split(','), (string s) => s.Trim());

			if (string.IsNullOrEmpty(tableName) || columnNames.Count <= 0)
				return;

			// get table by name
			Table table;
			if (!tables.TryGetValue(tableName, out table))
				throw new DdlException(
					string.Format("An additional index refers to a table ({0}) that does not exist.", table.Name),
					null);

			// get columns by name
			var columns = new List<Column>();
			foreach (var columnName in columnNames)
			{
				var column = CollectionUtils.SelectFirst(table.ColumnIterator, col => col.Name == columnName);
				// bug #6994: could be that the index file specifies a column name that does not actually exist, so we need to check for nulls
				if (column == null)
					throw new DdlException(
						string.Format("An additional index on table {0} refers to a column ({1}) that does not exist.", table.Name, columnName),
						null);
				columns.Add(column);
			}

			// create index
			CreateIndex(table, columns);
		}
Example #9
0
        public override string SqlTriggerBody(
      Dialect dialect, IMapping p, 
      string defaultCatalog, string defaultSchema)
        {
            var auditTableName = dialect.QuoteForTableName(_auditTableName);
              var eDialect = (IExtendedDialect)dialect;

              string triggerSource = _action == TriggerActions.DELETE ?
            eDialect.GetTriggerOldDataAlias() :
            eDialect.GetTriggerNewDataAlias();

              var columns = new List<string>(_dataColumnNames);
              columns.AddRange(from ac in _auditColumns
                       select ac.Name);

              var values = new List<string>();
              values.AddRange(
            from columnName in _dataColumnNames
            select eDialect.QualifyColumn(
              triggerSource, columnName));
              values.AddRange(
            from auditColumn in _auditColumns
            select auditColumn.ValueFunction.Invoke(_action));

              return eDialect.GetInsertIntoString(auditTableName,
            columns, triggerSource, values);
        }
        public static IList<Proyecto> ObtenerPorNombre(String nombre)
        {
            IList<Proyecto> proyecto = new List<Proyecto>();

            try
            {

                using (ISession session = Persistencia.SessionFactory.OpenSession())
                {
                    ICriteria criteria = session.CreateCriteria<Proyecto>();
                    criteria.Add(
                    Expression.Like("Nombre", nombre, MatchMode.Anywhere) /*||
                    Expression.Like("Responsable", nombre, MatchMode.Anywhere) ||
                    Expression.Like("TipoPrograma", nombre, MatchMode.Anywhere) ||
                    Expression.Like("Sector", nombre, MatchMode.Anywhere) ||
                    Expression.Like("Giro", nombre, MatchMode.Anywhere) ||
                    Expression.Like("Empresa", nombre, MatchMode.Anywhere) ||
                    Expression.Like("Telefono", nombre, MatchMode.Anywhere) ||
                    Expression.Like("Periodo", nombre, MatchMode.Anywhere) ||
                    Expression.Like("Horario", nombre, MatchMode.Anywhere) ||
                    Expression.Like("Horas", nombre, MatchMode.Anywhere)*/);
                    proyecto = criteria.List<Proyecto>();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return proyecto;
        }
		/// <summary>
		/// Constructor that creates a model from all NHibernate mappings and embedded enumeration information
		/// in the set of installed plugins.
		/// </summary>
		/// <param name="config"></param>
		/// <param name="namespaceFilter"></param>
		public RelationalModelInfo(Configuration config, RelationalSchemaOptions.NamespaceFilterOption namespaceFilter)
		{
			_tables = CollectionUtils.Map(GetTables(config, namespaceFilter), (Table table) => BuildTableInfo(table, config));

			_enumerations = CollectionUtils.Select(
				new EnumMetadataReader().GetEnums(config),
				enumeration => namespaceFilter.Matches(enumeration.EnumerationClass));
		}
		private Mapping.Collection CreateList(HbmList listMapping, string prefix, string path,
			PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas)
		{
			var list = new List(owner);
			BindCollection(listMapping, list, prefix, path, containingType, inheritedMetas);
			AddListSecondPass(listMapping, list, inheritedMetas);
			return list;
		}
 public void viewroots() {
     var result = new List<string>();
     result.Add(MonoRailConfiguration.GetConfig().ViewEngineConfig.ViewPathRoot);
    
     foreach (var path in MonoRailConfiguration.GetConfig().ViewEngineConfig.PathSources) {
         result.Add(path);
     }
     PropertyBag["result"] = result;
 }
Example #14
0
		internal ForeignKeyInfo(Table table, ForeignKey fk, Configuration config)
			: base("FK_", table.Name, fk.ColumnIterator, null)
		{
			//note: the fk object has a ReferencedTable property, but it doesn't always seem to be set
			//the reference class property is always set, so we use it instead to get the referenced table 
			Table referencedTable = config.GetClassMapping(fk.ReferencedEntityName).Table;
			_referencedTable = referencedTable.Name;
			_referencedColumns = CollectionUtils.Map<Column, string>(
                referencedTable.PrimaryKey.ColumnIterator,
				delegate(Column column) { return column.Name; });
		}
Example #15
0
 public System.Collections.IList GetObjects(string hql)
 {
     using (var factory = CreateSessionFactory(connectionString))
     using (var session = factory.OpenSession())
     {
         List<object> results = new List<object>();
         var query = session.CreateQuery(hql);
         query.List(results);
         return results;
     }
 }
Example #16
0
 public static List<Products> FeelProducts()
 {
     List<Products> result = new List<Products>
     {
         new Products{ Id = 1, Name = "LG", Declarations = "bla bla bla"},
         new Products{ Id = 2, Name = "Sumsung", Declarations = "bla bla bla"},
         new Products{ Id = 3, Name = "Apple", Declarations = "bla bla bla"},
         new Products{ Id = 4, Name = "Sony", Declarations = "bla bla bla"}
     };
     return result;
 }
Example #17
0
        public List<DiskContentModel> GetContentList(Directories dir)
        {
            var listOfDirectories = dir.SubFolder.ToList();
            var listOfContent = new List<DiskContentModel>();

            foreach (var dirs in listOfDirectories)
            {
                listOfContent.Add(Mapper.Map<Directories, DiskContentModel>(dirs));
            }
            return listOfContent;
        }
 /// <summary>
 /// Populate the metadata header.
 /// </summary>
 void InitMap()
 {
     _map = new Dictionary<string, object>();
     _typeList = new List<Dictionary<string, object>>();
     _typeNames = new HashSet<string>();
     _resourceMap = new Dictionary<string, object>();
     _fkMap = new Dictionary<string, string>();
     _map.Add("localQueryComparisonOptions", "caseInsensitiveSQL");
     _map.Add("structuralTypes", _typeList);
     _map.Add("resourceEntityTypeMap",_resourceMap);
     _map.Add(FK_MAP, _fkMap);
 }
		public override void CreateForeignKeyOfEntity(string entityName)
		{
			if (!HasFormula && !string.Equals("none", ForeignKeyName, StringComparison.InvariantCultureIgnoreCase))
			{
				var referencedColumns = new List<Column>(_prototype.ColumnSpan);
				foreach (Column column in _prototype.ColumnIterator)
				{
					referencedColumns.Add(column);
				}

				ForeignKey fk = Table.CreateForeignKey(ForeignKeyName, ConstraintColumns, entityName, referencedColumns);
				fk.CascadeDeleteEnabled = IsCascadeDeleteEnabled;
			}
		}
Example #20
0
        public Class(Mapper mapper)
            : base(mapper)
        {
            _versionTypes = new List<Type>(3)
                                {
                                    typeof (short),
                                    typeof (int),
                                    typeof (long)
                                };

            Mapper.IsEntity(IsEntity);
            Mapper.IsRootEntity(IsRootEntity);
            Mapper.IsVersion(IsVersion);
        }
        public string[] GenerateSchemaDropScriptAuxiliaryDatabaseObjects(Func<IAuxiliaryDatabaseObject, bool> predicate)
        {
            Dialect dialect = Dialect.GetDialect(Properties);
            string defaultCatalog = PropertiesHelper.GetString("default_catalog", Properties, null);
            string defaultSchema = PropertiesHelper.GetString("default_schema", Properties, null);
            List<string> list = new List<string>();
            foreach (IAuxiliaryDatabaseObject obj2 in auxiliaryDatabaseObjects.Where(predicate))
            {
                if (obj2.AppliesToDialect(dialect))
                {
                    list.Add(obj2.SqlDropString(dialect,defaultCatalog, defaultSchema));
                }
            }

            return list.ToArray();
        }
 public AnalysisChromatograms(PeptideFileAnalysis peptideFileAnalysis)
 {
     PeptideFileAnalysis = peptideFileAnalysis;
     FirstTime = peptideFileAnalysis.FirstTime;
     LastTime = peptideFileAnalysis.LastTime;
     Chromatograms = new List<ChromatogramGenerator.Chromatogram>();
     for (int charge = PeptideAnalysis.MinCharge; charge <= PeptideAnalysis.MaxCharge; charge ++)
     {
         var mzs = PeptideAnalysis.TurnoverCalculator.GetMzs(charge);
         for (int massIndex = 0; massIndex < mzs.Count; massIndex ++)
         {
             Chromatograms.Add(new ChromatogramGenerator.Chromatogram(new MzKey(charge, massIndex), mzs[massIndex]));
         }
     }
     ScanIndexes = new List<int>();
     Times = new List<double>();
 }
 public void AddPoints(int scanIndex, double time, List<MsDataFileUtil.ChromatogramPoint> points)
 {
     if (ScanIndexes.Count > 0)
     {
         Debug.Assert(scanIndex > ScanIndexes[ScanIndexes.Count - 1]);
         Debug.Assert(time >= Times[Times.Count - 1]);
     }
     ScanIndexes.Add(scanIndex);
     Times.Add(time);
     for (int i = 0; i < Chromatograms.Count; i ++)
     {
         var chromatogram = Chromatograms[i];
         var point = points[i];
         chromatogram.Intensities.Add((float) point.Intensity);
         chromatogram.PeakMzs.Add((float) point.PeakMz);
     }
 }
Example #24
0
		public NPCSpellCollection(NPC owner)
			: base(owner, false)
		{
			m_byId = owner.Entry.Spells;
			m_readySpells = new List<Spell>();
			if (m_byId != null)
			{
				m_defaultSpells = true;
				foreach (var spell in m_byId.Values)
				{
					AddReadySpell(spell);
					OnNewSpell(spell);
				}
			}
			else
			{
				m_defaultSpells = false;
				m_byId = new Dictionary<uint, Spell>(5);
			}
		}
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var siteCopyOptions = new List<SiteCopyOption>();

            NameValueCollection form = controllerContext.HttpContext.Request.Form;
            IEnumerable<string> keys = form.AllKeys.Where(s => s.StartsWith("sco-"));

            foreach (string key in keys)
            {
                string value = form[key];
                int id;
                string typeName = key.Substring(4);
                Type type = TypeHelper.GetTypeByName(typeName);
                if (int.TryParse(value, out id) && type != null)
                {
                    siteCopyOptions.Add(new SiteCopyOption {SiteCopyActionType = type, SiteId = id});
                }
            }

            return siteCopyOptions;
        }
Example #26
0
		/// <summary>
		/// Provide the list of progressive-paths
		/// </summary>
		/// <param name="source"></param>
		/// <returns>
		/// Given a path as : Pl1.Pl2.Pl3.Pl4.Pl5 returns paths-sequence as:
		/// Pl5
		/// Pl4.Pl5
		/// Pl3.Pl4.Pl5
		/// Pl2.Pl3.Pl4.Pl5
		/// Pl1.Pl2.Pl3.Pl4.Pl5
		/// </returns>
		public static IEnumerable<PropertyPath> InverseProgressivePath(this PropertyPath source)
		{
			if (source == null)
			{
				throw new ArgumentNullException("source");
			}
			var analizing = source;
			var returnLocalMembers = new List<MemberInfo>(10);
			do
			{
				returnLocalMembers.Add(analizing.LocalMember);
				PropertyPath progressivePath = null;
				for (int i = returnLocalMembers.Count -1; i >= 0; i--)
				{
					progressivePath = new PropertyPath(progressivePath, returnLocalMembers[i]);
				}
				yield return progressivePath;
				analizing = analizing.PreviousPath;
			}
			while (analizing != null);
		}
Example #27
0
        private void AddAuditing(Mappings mappings)
        {
            var auditObjects = new List<IAuxiliaryDatabaseObject>();
              foreach (var table in mappings.IterateTables.ToArray())
              {
            var auditTable = new AuditTable(
              table, _namingStrategy, _columnSource);
            mappings.AddAuxiliaryDatabaseObject(auditTable);

            var insertTrigger = new AuditTrigger(table,
              auditTable, _namingStrategy, TriggerActions.INSERT);
            mappings.AddAuxiliaryDatabaseObject(insertTrigger);

            var updateTrigger = new AuditTrigger(table,
              auditTable, _namingStrategy, TriggerActions.UPDATE);
            mappings.AddAuxiliaryDatabaseObject(updateTrigger);

            var deleteTrigger = new AuditTrigger(table,
              auditTable, _namingStrategy, TriggerActions.DELETE);
            mappings.AddAuxiliaryDatabaseObject(deleteTrigger);
              }
        }
Example #28
0
        static void Main(string[] args)
        {
            var results = new List<TestResult>();
            results.Add(AdoDataAccess());
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);

            results.Add(DapperDataAccess());
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);

            results.Add(EfDataAccess());
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);

            results.Add(EfFastDataAccess());
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);

            results.Add(NhDataAccess());

            ConsoleTable.From(results).Write();

            Console.WriteLine("Teste finalizado");
            Console.ReadKey();
        }
		protected AbstractEntityPersister(PersistentClass persistentClass, ICacheConcurrencyStrategy cache,
																			ISessionFactoryImplementor factory)
		{
			this.factory = factory;
			this.cache = cache;
			isLazyPropertiesCacheable = persistentClass.IsLazyPropertiesCacheable;
			cacheEntryStructure = factory.Settings.IsStructuredCacheEntriesEnabled
															? (ICacheEntryStructure)new StructuredCacheEntry(this)
															: (ICacheEntryStructure)new UnstructuredCacheEntry();

			entityMetamodel = new EntityMetamodel(persistentClass, factory);

			if (persistentClass.HasPocoRepresentation)
			{
				//TODO: this is currently specific to pojos, but need to be available for all entity-modes
				foreach (Subclass subclass in persistentClass.SubclassIterator)
				{
					entityNameBySubclass[subclass.MappedClass] = subclass.EntityName;
				}
			}

			batchSize = persistentClass.BatchSize.HasValue ? persistentClass.BatchSize.Value : factory.Settings.DefaultBatchFetchSize;
			hasSubselectLoadableCollections = persistentClass.HasSubselectLoadableCollections;

			propertyMapping = new BasicEntityPropertyMapping(this);

			#region IDENTIFIER

			identifierColumnSpan = persistentClass.Identifier.ColumnSpan;
			rootTableKeyColumnNames = new string[identifierColumnSpan];
			identifierAliases = new string[identifierColumnSpan];

			rowIdName = persistentClass.RootTable.RowId;

			loaderName = persistentClass.LoaderName;

			// TODO NH: Not safe cast to Column
			int i = 0;
			foreach (Column col in persistentClass.Identifier.ColumnIterator)
			{
				rootTableKeyColumnNames[i] = col.GetQuotedName(factory.Dialect);
				identifierAliases[i] = col.GetAlias(factory.Dialect, persistentClass.RootTable);
				i++;
			}

			#endregion

			#region VERSION

			if (persistentClass.IsVersioned)
			{
				foreach (Column col in persistentClass.Version.ColumnIterator)
				{
					versionColumnName = col.GetQuotedName(factory.Dialect);
					break; //only happens once
				}
			}
			else
			{
				versionColumnName = null;
			}

			#endregion

			#region WHERE STRING

			sqlWhereString = !string.IsNullOrEmpty(persistentClass.Where) ? "( " + persistentClass.Where + ") " : null;
			sqlWhereStringTemplate = sqlWhereString == null
																? null
																: Template.RenderWhereStringTemplate(sqlWhereString, factory.Dialect,
																																		 factory.SQLFunctionRegistry);

			#endregion

			#region PROPERTIES

			// NH: see consistence with the implementation on EntityMetamodel where we are disabling lazy-properties for no lazy entities
			bool lazyAvailable = IsInstrumented(EntityMode.Poco) && entityMetamodel.IsLazy;

			int hydrateSpan = entityMetamodel.PropertySpan;
			propertyColumnSpans = new int[hydrateSpan];
			propertySubclassNames = new string[hydrateSpan];
			propertyColumnAliases = new string[hydrateSpan][];
			propertyColumnNames = new string[hydrateSpan][];
			propertyColumnFormulaTemplates = new string[hydrateSpan][];
			propertyUniqueness = new bool[hydrateSpan];
			propertySelectable = new bool[hydrateSpan];
			propertyColumnUpdateable = new bool[hydrateSpan][];
			propertyColumnInsertable = new bool[hydrateSpan][];
			var thisClassProperties = new HashSet<Property>();

			lazyProperties = new HashedSet<string>();
			List<string> lazyNames = new List<string>();
			List<int> lazyNumbers = new List<int>();
			List<IType> lazyTypes = new List<IType>();
			List<string[]> lazyColAliases = new List<string[]>();

			i = 0;
			bool foundFormula = false;
			foreach (Property prop in persistentClass.PropertyClosureIterator)
			{
				thisClassProperties.Add(prop);

				int span = prop.ColumnSpan;
				propertyColumnSpans[i] = span;
				propertySubclassNames[i] = prop.PersistentClass.EntityName;
				string[] colNames = new string[span];
				string[] colAliases = new string[span];
				string[] templates = new string[span];
				int k = 0;
				foreach (ISelectable thing in prop.ColumnIterator)
				{
					colAliases[k] = thing.GetAlias(factory.Dialect, prop.Value.Table);
					if (thing.IsFormula)
					{
						foundFormula = true;
						templates[k] = thing.GetTemplate(factory.Dialect, factory.SQLFunctionRegistry);
					}
					else
					{
						colNames[k] = thing.GetTemplate(factory.Dialect, factory.SQLFunctionRegistry);
					}
					k++;
				}
				propertyColumnNames[i] = colNames;
				propertyColumnFormulaTemplates[i] = templates;
				propertyColumnAliases[i] = colAliases;

				if (lazyAvailable && prop.IsLazy)
				{
					lazyProperties.Add(prop.Name);
					lazyNames.Add(prop.Name);
					lazyNumbers.Add(i);
					lazyTypes.Add(prop.Value.Type);
					lazyColAliases.Add(colAliases);
				}

				propertyColumnUpdateable[i] = prop.Value.ColumnUpdateability;
				propertyColumnInsertable[i] = prop.Value.ColumnInsertability;

				propertySelectable[i] = prop.IsSelectable;

				propertyUniqueness[i] = prop.Value.IsAlternateUniqueKey;

				i++;
			}
			hasFormulaProperties = foundFormula;
			lazyPropertyColumnAliases = lazyColAliases.ToArray();
			lazyPropertyNames = lazyNames.ToArray();
			lazyPropertyNumbers = lazyNumbers.ToArray();
			lazyPropertyTypes = lazyTypes.ToArray();

			#endregion

			#region SUBCLASS PROPERTY CLOSURE

			List<string> columns = new List<string>();
			List<bool> columnsLazy = new List<bool>();
			List<string> aliases = new List<string>();
			List<string> formulas = new List<string>();
			List<string> formulaAliases = new List<string>();
			List<string> formulaTemplates = new List<string>();
			List<bool> formulasLazy = new List<bool>();
			List<IType> types = new List<IType>();
			List<string> names = new List<string>();
			List<string> classes = new List<string>();
			List<string[]> templates2 = new List<string[]>();
			List<string[]> propColumns = new List<string[]>();
			List<FetchMode> joinedFetchesList = new List<FetchMode>();
			List<CascadeStyle> cascades = new List<CascadeStyle>();
			List<bool> definedBySubclass = new List<bool>();
			List<int[]> propColumnNumbers = new List<int[]>();
			List<int[]> propFormulaNumbers = new List<int[]>();
			List<bool> columnSelectables = new List<bool>();
			List<bool> propNullables = new List<bool>();

			foreach (Property prop in persistentClass.SubclassPropertyClosureIterator)
			{
				names.Add(prop.Name);
				classes.Add(prop.PersistentClass.EntityName);
				bool isDefinedBySubclass = !thisClassProperties.Contains(prop);
				definedBySubclass.Add(isDefinedBySubclass);
				propNullables.Add(prop.IsOptional || isDefinedBySubclass); //TODO: is this completely correct?
				types.Add(prop.Type);

				string[] cols = new string[prop.ColumnSpan];
				string[] forms = new string[prop.ColumnSpan];
				int[] colnos = new int[prop.ColumnSpan];
				int[] formnos = new int[prop.ColumnSpan];
				int l = 0;
				bool lazy = prop.IsLazy && lazyAvailable;
				foreach (ISelectable thing in prop.ColumnIterator)
				{
					if (thing.IsFormula)
					{
						string template = thing.GetTemplate(factory.Dialect, factory.SQLFunctionRegistry);
						formnos[l] = formulaTemplates.Count;
						colnos[l] = -1;
						formulaTemplates.Add(template);
						forms[l] = template;
						formulas.Add(thing.GetText(factory.Dialect));
						formulaAliases.Add(thing.GetAlias(factory.Dialect));
						formulasLazy.Add(lazy);
					}
					else
					{
						string colName = thing.GetTemplate(factory.Dialect, factory.SQLFunctionRegistry);
						colnos[l] = columns.Count; //before add :-)
						formnos[l] = -1;
						columns.Add(colName);
						cols[l] = colName;
						aliases.Add(thing.GetAlias(factory.Dialect, prop.Value.Table));
						columnsLazy.Add(lazy);
						columnSelectables.Add(prop.IsSelectable);
					}
					l++;
				}
				propColumns.Add(cols);
				templates2.Add(forms);
				propColumnNumbers.Add(colnos);
				propFormulaNumbers.Add(formnos);

				joinedFetchesList.Add(prop.Value.FetchMode);
				cascades.Add(prop.CascadeStyle);
			}
			subclassColumnClosure = columns.ToArray();
			subclassColumnAliasClosure = aliases.ToArray();
			subclassColumnLazyClosure = columnsLazy.ToArray();
			subclassColumnSelectableClosure = columnSelectables.ToArray();

			subclassFormulaClosure = formulas.ToArray();
			subclassFormulaTemplateClosure = formulaTemplates.ToArray();
			subclassFormulaAliasClosure = formulaAliases.ToArray();
			subclassFormulaLazyClosure = formulasLazy.ToArray();

			subclassPropertyNameClosure = names.ToArray();
			subclassPropertySubclassNameClosure = classes.ToArray();
			subclassPropertyTypeClosure = types.ToArray();
			subclassPropertyNullabilityClosure = propNullables.ToArray();
			subclassPropertyFormulaTemplateClosure = templates2.ToArray();
			subclassPropertyColumnNameClosure = propColumns.ToArray();
			subclassPropertyColumnNumberClosure = propColumnNumbers.ToArray();
			subclassPropertyFormulaNumberClosure = propFormulaNumbers.ToArray();

			subclassPropertyCascadeStyleClosure = cascades.ToArray();
			subclassPropertyFetchModeClosure = joinedFetchesList.ToArray();

			propertyDefinedOnSubclass = definedBySubclass.ToArray();

			#endregion

			// Handle any filters applied to the class level
			filterHelper = new FilterHelper(persistentClass.FilterMap, factory.Dialect, factory.SQLFunctionRegistry);

			temporaryIdTableName = persistentClass.TemporaryIdTableName;
			temporaryIdTableDDL = persistentClass.TemporaryIdTableDDL;
		}
		protected internal virtual SqlString GenerateLazySelectString()
		{
			if (!entityMetamodel.HasLazyProperties)
				return null;

			HashedSet<int> tableNumbers = new HashedSet<int>();
			List<int> columnNumbers = new List<int>();
			List<int> formulaNumbers = new List<int>();
			for (int i = 0; i < lazyPropertyNames.Length; i++)
			{
				// all this only really needs to consider properties
				// of this class, not its subclasses, but since we
				// are reusing code used for sequential selects, we
				// use the subclass closure
				int propertyNumber = GetSubclassPropertyIndex(lazyPropertyNames[i]);

				int tableNumber = GetSubclassPropertyTableNumber(propertyNumber);
				tableNumbers.Add(tableNumber);

				int[] colNumbers = subclassPropertyColumnNumberClosure[propertyNumber];
				for (int j = 0; j < colNumbers.Length; j++)
				{
					if (colNumbers[j] != -1)
					{
						columnNumbers.Add(colNumbers[j]);
					}
				}
				int[] formNumbers = subclassPropertyFormulaNumberClosure[propertyNumber];
				for (int j = 0; j < formNumbers.Length; j++)
				{
					if (formNumbers[j] != -1)
					{
						formulaNumbers.Add(formNumbers[j]);
					}
				}
			}

			if (columnNumbers.Count == 0 && formulaNumbers.Count == 0)
			{
				// only one-to-one is lazy fetched
				return null;
			}

			return RenderSelect(tableNumbers.ToArray(), columnNumbers.ToArray(), formulaNumbers.ToArray());
		}