public SqlExpression BuildProjection(SqlExpression item, MetaType rowType, bool allowDeferred, SqlLink link, Expression source) { if (!rowType.HasInheritance) { return(BuildProjectionInternal(item, rowType, (rowType.Table != null) ? rowType.PersistentDataMembers : rowType.DataMembers, allowDeferred, link, source)); } var list = new List <MetaType>(rowType.InheritanceTypes); var list2 = new List <SqlTypeCaseWhen>(); SqlTypeCaseWhen when = null; MetaType inheritanceRoot = rowType.InheritanceRoot; MetaDataMember discriminator = inheritanceRoot.Discriminator; Type type = discriminator.Type; SqlMember member2 = sql.Member(item, discriminator.Member); foreach (MetaType type3 in list) { if (type3.HasInheritanceCode) { SqlNew typeBinding = BuildProjectionInternal(item, type3, type3.PersistentDataMembers, allowDeferred, link, source); if (type3.IsInheritanceDefault) { when = new SqlTypeCaseWhen(null, typeBinding); } object obj2 = InheritanceRules.InheritanceCodeForClientCompare(type3.InheritanceCode, member2.SqlType); SqlExpression match = sql.Value(type, sql.Default(discriminator), obj2, true, source); list2.Add(new SqlTypeCaseWhen(match, typeBinding)); } } if (when == null) { throw Error.EmptyCaseNotSupported(); } list2.Add(when); return(sql.TypeCase(inheritanceRoot.Type, inheritanceRoot, member2, list2.ToArray(), source)); }
private static bool IsSupportedMember(SqlMember m) { if (!IsNullableHasValue(m)) { return(IsNullableHasValue(m)); } return(true); }
protected override SqlNode VisitMember(SqlMember m) { m.Expression = this.VisitExpression(m.Expression); if (IsNullableValue(m)) { return(sql.UnaryValueOf(m.Expression, m.SourceExpression)); } if (IsNullableHasValue(m)) { return(sql.Unary(SqlNodeType.IsNotNull, m.Expression, m.SourceExpression)); } return(m); }
protected virtual SqlNode VisitMember(SqlMember m) { m.Expression = this.VisitExpression(m.Expression); return(m); }
protected override SqlNode VisitMember(SqlMember m) { return(new SqlMember(m.ClrType, m.SqlType, (SqlExpression)this.Visit(m.Expression), m.Member)); }
private static bool IsNullableValue(SqlMember m) { return(TypeSystem.IsNullableType(m.Expression.ClrType) && (m.Member.Name == "Value")); }