当前位置: 首页>>代码示例>>C#>>正文


C# Dialect.ApplyLocksToSql方法代码示例

本文整理汇总了C#中Dialect.ApplyLocksToSql方法的典型用法代码示例。如果您正苦于以下问题:C# Dialect.ApplyLocksToSql方法的具体用法?C# Dialect.ApplyLocksToSql怎么用?C# Dialect.ApplyLocksToSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dialect的用法示例。


在下文中一共展示了Dialect.ApplyLocksToSql方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyLocks

		protected override SqlString ApplyLocks(SqlString sql, IDictionary<string, LockMode> lockModes,
		                                        Dialect.Dialect dialect)
		{
			if (lockModes == null || lockModes.Count == 0)
			{
				return sql;
			}

			// can't cache this stuff either (per-invocation)
			// we are given a map of user-alias -> lock mode
			// create a new map of sql-alias -> lock mode
			var aliasedLockModes = new Dictionary<string, LockMode>();
			Dictionary<string, string[]> keyColumnNames = dialect.ForUpdateOfColumns ? new Dictionary<string, string[]>() : null;

			foreach (var entry in lockModes)
			{
				string userAlias = entry.Key;
				string drivingSqlAlias = _sqlAliasByEntityAlias[userAlias];
				if (drivingSqlAlias == null)
				{
					throw new InvalidOperationException("could not locate alias to apply lock mode : " + userAlias);
				}

				// at this point we have (drivingSqlAlias) the SQL alias of the driving table
				// corresponding to the given user alias.  However, the driving table is not
				// (necessarily) the table against which we want to apply locks.  Mainly,
				// the exception case here is joined-subclass hierarchies where we instead
				// want to apply the lock against the root table (for all other strategies,
				// it just happens that driving and root are the same).
				var select = (QueryNode) _queryTranslator.SqlAST;
				var drivingPersister = (ILockable) select.FromClause.GetFromElement(userAlias).Queryable;
				string sqlAlias = drivingPersister.GetRootTableAlias(drivingSqlAlias);
				aliasedLockModes.Add(sqlAlias, entry.Value);

				if (keyColumnNames != null)
				{
					keyColumnNames.Add(sqlAlias, drivingPersister.RootTableIdentifierColumnNames);
				}
			}

			return dialect.ApplyLocksToSql(sql, aliasedLockModes, keyColumnNames);
		}
开发者ID:dpupek,项目名称:nhibernate-core,代码行数:42,代码来源:QueryLoader.cs

示例2: ApplyLocks

		protected override SqlString ApplyLocks(SqlString sqlSelectString, IDictionary<string, LockMode> lockModes,
												Dialect.Dialect dialect)
		{
			if (lockModes == null || lockModes.Count == 0)
			{
				return sqlSelectString;
			}

			Dictionary<string, LockMode> aliasedLockModes = new Dictionary<string, LockMode>();
			Dictionary<string, string[]> keyColumnNames = dialect.ForUpdateOfColumns ? new Dictionary<string, string[]>() : null;
			string[] drivingSqlAliases = Aliases;

			//NH-3710: if we are issuing an aggregation function, Aliases will be null
			if (drivingSqlAliases != null)
			{
				for (int i = 0; i < drivingSqlAliases.Length; i++)
				{
					LockMode lockMode;
					if (lockModes.TryGetValue(drivingSqlAliases[i], out lockMode))
					{
						ILockable drivingPersister = (ILockable)EntityPersisters[i];
						string rootSqlAlias = drivingPersister.GetRootTableAlias(drivingSqlAliases[i]);
						aliasedLockModes[rootSqlAlias] = lockMode;
						if (keyColumnNames != null)
						{
							keyColumnNames[rootSqlAlias] = drivingPersister.RootTableIdentifierColumnNames;
						}
					}
				}
			}

			return dialect.ApplyLocksToSql(sqlSelectString, aliasedLockModes, keyColumnNames);
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:33,代码来源:CriteriaLoader.cs

示例3: ApplyLocks

		protected override SqlString ApplyLocks(SqlString sql, IDictionary<string, LockMode> lockModes, Dialect.Dialect dialect)
		{
			SqlString result;
			if (lockModes == null || lockModes.Count == 0)
			{
				result = sql;
			}
			else
			{
				Dictionary<string, LockMode> aliasedLockModes = new Dictionary<string, LockMode>();
				foreach (KeyValuePair<string, LockMode> de in lockModes)
				{
					aliasedLockModes[GetAliasName(de.Key)] = de.Value;
				}

				Dictionary<string,string[]> keyColumnNames = null;
				if (dialect.ForUpdateOfColumns)
				{
					keyColumnNames = new Dictionary<string, string[]>();
					for (int i = 0; i < names.Length; i++)
					{
						keyColumnNames[names[i]] = persisters[i].IdentifierColumnNames;
					}
				}
				result = dialect.ApplyLocksToSql(sql, aliasedLockModes, keyColumnNames);
			}
			LogQuery(queryString, result.ToString());
			return result;
		}
开发者ID:rbirkby,项目名称:nhibernate-core,代码行数:29,代码来源:QueryTranslator.cs

示例4: BuildSelectQuery

		protected void BuildSelectQuery(Dialect.Dialect dialect)
		{
			const string alias = "tbl";
			SqlString select = new SqlString(
				"select ", StringHelper.Qualify(alias, ValueColumnName), 
				" from ", TableName, " ", alias,
				" where ", StringHelper.Qualify(alias, SegmentColumnName), " = ", Parameter.Placeholder, 
				"  ");

			Dictionary<string, LockMode> lockOptions = new Dictionary<string, LockMode>();
			lockOptions[alias] = LockMode.Upgrade;

			Dictionary<string, string[]> updateTargetColumnsMap = new Dictionary<string, string[]>();
			updateTargetColumnsMap[alias] = new[] { ValueColumnName };

			selectQuery = dialect.ApplyLocksToSql(select, lockOptions, updateTargetColumnsMap);

			selectParameterTypes = new[] { SqlTypes.SqlTypeFactory.GetAnsiString(SegmentValueLength) };
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:19,代码来源:TableGenerator.cs

示例5: BuildSelectQuery

		protected void BuildSelectQuery(Dialect.Dialect dialect)
		{
			const string alias = "tbl";
			SqlStringBuilder selectBuilder = new SqlStringBuilder(100);
			selectBuilder.Add("select ").Add(StringHelper.Qualify(alias, ValueColumnName))
				.Add(" from " + TableName + " " + alias + " where ")
				.Add(StringHelper.Qualify(alias, SegmentColumnName) + " = ")
				.AddParameter().Add("  ");

			Dictionary<string, LockMode> lockOptions = new Dictionary<string, LockMode>();
			lockOptions[alias] = LockMode.Upgrade;

			Dictionary<string, string[]> updateTargetColumnsMap = new Dictionary<string, string[]>();
			updateTargetColumnsMap[alias] = new[] { ValueColumnName };

			selectQuery = dialect.ApplyLocksToSql(selectBuilder.ToSqlString(), lockOptions, updateTargetColumnsMap);

			selectParameterTypes = new[] { SqlTypes.SqlTypeFactory.GetAnsiString(SegmentValueLength) };
		}
开发者ID:ntuveri,项目名称:nhibernate-core,代码行数:19,代码来源:TableGenerator.cs

示例6: ApplyLocks

		protected override SqlString ApplyLocks(SqlString sqlSelectString, IDictionary lockModes, Dialect.Dialect dialect)
		{
			if (lockModes == null || lockModes.Count == 0)
			{
				return sqlSelectString;
			}

			IDictionary keyColumnNames = null;
			ILoadable[] persisters = EntityPersisters;
			string[] entityAliases = Aliases;

			if (dialect.ForUpdateOfColumns)
			{
				keyColumnNames = new Hashtable();
				for (int i = 0; i < entityAliases.Length; i++)
				{
					keyColumnNames[entityAliases[i]] = persisters[i].IdentifierColumnNames;
				}
			}

			return dialect.ApplyLocksToSql(sqlSelectString, lockModes, keyColumnNames);
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:22,代码来源:CriteriaLoader.cs


注:本文中的Dialect.ApplyLocksToSql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。