/// <summary> /// Generate a select list of columns containing all properties of the entity classes /// </summary> public string SelectString(IList <OuterJoinableAssociation> associations) { if (associations.Count == 0) { return(string.Empty); } else { SqlStringBuilder buf = new SqlStringBuilder(associations.Count * 3); int entityAliasCount = 0; int collectionAliasCount = 0; for (int i = 0; i < associations.Count; i++) { OuterJoinableAssociation join = associations[i]; OuterJoinableAssociation next = (i == associations.Count - 1) ? null : associations[i + 1]; IJoinable joinable = join.Joinable; string entitySuffix = (suffixes == null || entityAliasCount >= suffixes.Length) ? null : suffixes[entityAliasCount]; string collectionSuffix = (collectionSuffixes == null || collectionAliasCount >= collectionSuffixes.Length) ? null : collectionSuffixes[collectionAliasCount]; string selectFragment = joinable.SelectFragment(next == null ? null : next.Joinable, next == null ? null : next.RHSAlias, join.RHSAlias, entitySuffix, collectionSuffix, join.JoinType == JoinType.LeftOuterJoin); if (selectFragment.Trim().Length > 0) { buf.Add(StringHelper.CommaSpace) .Add(selectFragment); } if (joinable.ConsumesEntityAlias()) { entityAliasCount++; } if (joinable.ConsumesCollectionAlias() && join.JoinType == JoinType.LeftOuterJoin) { collectionAliasCount++; } } return(buf.ToSqlString().ToString()); } }
/// <summary> /// Generate a select list of columns containing all properties of the entity classes /// </summary> public string SelectString(IList <OuterJoinableAssociation> associations) { if (associations.Count == 0) { return(string.Empty); } else { SqlStringBuilder buf = new SqlStringBuilder(associations.Count * 3); int entityAliasCount = 0; int collectionAliasCount = 0; for (int i = 0; i < associations.Count; i++) { OuterJoinableAssociation join = associations[i]; OuterJoinableAssociation next = (i == associations.Count - 1) ? null : associations[i + 1]; IJoinable joinable = join.Joinable; string entitySuffix = (suffixes == null || entityAliasCount >= suffixes.Length) ? null : suffixes[entityAliasCount]; string collectionSuffix = (collectionSuffixes == null || collectionAliasCount >= collectionSuffixes.Length) ? null : collectionSuffixes[collectionAliasCount]; string selectFragment = GetSelectFragment(join, entitySuffix, collectionSuffix, next); if (!string.IsNullOrWhiteSpace(selectFragment)) { buf.Add(StringHelper.CommaSpace) .Add(selectFragment); } if (joinable.ConsumesEntityAlias() && join.SelectMode != SelectMode.JoinOnly) { entityAliasCount++; } if (joinable.ConsumesCollectionAlias() && join.ShouldFetchCollectionPersister()) { collectionAliasCount++; } } return(buf.ToSqlString().ToString()); } }