示例#1
0
        public override LambdaExpression CreateMaterializer(IEntityType entityType, SelectExpression selectExpression, Func <IProperty, SelectExpression, int> projectionAdder,
                                                            out Dictionary <Type, int[]> typeIndexMap)
        {
            if (selectExpression == null)
            {
                throw new ArgumentNullException(nameof(selectExpression));
            }

            RelationalQueryCompilationContext queryCompilationContext =
                _getQueryCompilationContext(selectExpression);
            var isWithNoLock = queryCompilationContext.QueryAnnotations.OfType <WithNoLockResultOperator>().Any();

            if (isWithNoLock)
            {
                IEnumerable <TableExpression> tableExpressions = selectExpression.Tables.OfType <TableExpression>().ToArray();
                foreach (TableExpression tableExpression in tableExpressions)
                {
                    WithNoLockTableExpression withNoLockTableExpression =
                        new WithNoLockTableExpression(tableExpression.Table, tableExpression.Schema,
                                                      tableExpression.Alias, tableExpression.QuerySource);
                    selectExpression.RemoveTable(tableExpression);
                    selectExpression.AddTable(withNoLockTableExpression);
                }
            }


            return(base.CreateMaterializer(entityType, selectExpression, projectionAdder, out typeIndexMap));
        }
 private bool Equals(WithNoLockTableExpression other)
 => string.Equals(Table, other.Table) &&
 string.Equals(Schema, other.Schema) &&
 string.Equals(Alias, other.Alias) &&
 Equals(QuerySource, other.QuerySource);