示例#1
0
        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;
            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, lockModes, keyColumnNames));
        }