コード例 #1
0
		protected virtual SqlString GenerateSnapshotSelectString()
		{
			//TODO: should we use SELECT .. FOR UPDATE?

			SqlSelectBuilder select = new SqlSelectBuilder(Factory);

			//if (Factory.Settings.IsCommentsEnabled)
			//{
			//    select.SetComment("get current state " + ClassName);
			//}

			string[] aliasedIdColumns = StringHelper.Qualify(RootAlias, IdentifierColumnNames);
			string selectClause = StringHelper.Join(", ", aliasedIdColumns) +
			                      ConcretePropertySelectFragment(RootAlias, PropertyUpdateability);

			SqlString fromClause = new SqlString(FromTableFragment(RootAlias)) +
			                       FromJoinFragment(RootAlias, true, false);

			SqlString joiner = new SqlString("=", Parameter.Placeholder, " and ");
			SqlString whereClause = new SqlStringBuilder()
				.Add(StringHelper.Join(joiner, aliasedIdColumns))
				.Add("=")
				.AddParameter()
				.Add(WhereJoinFragment(RootAlias, true, false))
				.ToSqlString();

			// TODO H3: this is commented out in H3.2
			if (IsVersioned)
			{
				whereClause.Append(" and ")
					.Append(VersionColumnName)
					.Append("=?");
			}

			return select.SetSelectClause(selectClause)
				.SetFromClause(fromClause)
				.SetOuterJoins(SqlString.Empty, SqlString.Empty)
				.SetWhereClause(whereClause)
				.ToSqlString();
		}