using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace System.Data.Linq.SqlClient {
///
/// Binds MemberAccess
/// Prefetches deferrable expressions (SqlLink) if necessary
/// Translates structured object comparision (EQ, NE) into memberwise comparison
/// Translates shared expressions (SqlSharedExpression, SqlSharedExpressionRef)
/// Optimizes out simple redundant operations :
/// XXX OR TRUE ==> TRUE
/// XXX AND FALSE ==> FALSE
/// NON-NULL EQ NULL ==> FALSE
/// NON-NULL NEQ NULL ==> TRUE
///
internal class SqlBinder {
SqlColumnizer columnizer;
Visitor visitor;
SqlFactory sql;
Func prebinder;
bool optimizeLinkExpansions = true;
bool simplifyCaseStatements = true;
internal SqlBinder(Translator translator, SqlFactory sqlFactory, MetaModel model, DataLoadOptions shape, SqlColumnizer columnizer, bool canUseOuterApply) {
this.sql = sqlFactory;
this.columnizer = columnizer;
this.visitor = new Visitor(this, translator, this.columnizer, this.sql, model, shape, canUseOuterApply);
}
internal Func PreBinder {
get { return this.prebinder; }
set { this.prebinder = value; }
}
private SqlNode Prebind(SqlNode node) {
if (this.prebinder != null) {
node = this.prebinder(node);
}
return node;
}
class LinkOptimizationScope {
Dictionary