Ejemplo n.º 1
0
            //Verifies that the Sets we got from visiting the tree( under AssociationType constructor) match the ones
            //defined in CSDL
            private void ValidateEntitySetsMappedForAssociationSetMapping(DbExpressionStructuralTypeEntitySetInfo setInfos)
            {
                AssociationSet associationSet = _setMapping.Set as AssociationSet;
                int            i = 0;

                //While we should be able to find the EntitySets in all cases, since this is a user specified
                //query view, it is better to be defensive since we might have missed some path up the tree
                //while computing the sets
                if (setInfos.SetInfos.All(it => ((it.Value != null) && (it.Value is DbExpressionSimpleTypeEntitySetInfo))) &&
                    setInfos.SetInfos.Count() == 2)
                {
                    foreach (DbExpressionSimpleTypeEntitySetInfo setInfo in setInfos.SetInfos.Select(it => it.Value))
                    {
                        AssociationSetEnd setEnd      = associationSet.AssociationSetEnds[i];
                        EntitySet         declaredSet = setEnd.EntitySet;
                        if (!declaredSet.Equals(setInfo.EntitySet))
                        {
                            _errors.Add(new EdmSchemaError(System.Data.Entity.Strings.Mapping_EntitySetMismatchOnAssociationSetEnd_QueryView(
                                                               setInfo.EntitySet.Name, declaredSet.Name, setEnd.Name, _setMapping.Set.Name), (int)StorageMappingErrorCode.MappingUnsupportedInitializationQueryView,
                                                           EdmSchemaErrorSeverity.Error, _setMapping.EntityContainerMapping.SourceLocation, _setMapping.StartLineNumber,
                                                           _setMapping.StartLinePosition));
                        }
                        i++;
                    }
                }
            }
Ejemplo n.º 2
0
            public override DbExpressionEntitySetInfo Visit(DbNewInstanceExpression expression)
            {
                Check.NotNull(expression, "expression");

                var argumentSetInfos = VisitExpressionList(expression.Arguments);
                var structuralType   = (expression.ResultType.EdmType as StructuralType);

                if (argumentSetInfos != null &&
                    structuralType != null)
                {
                    var structuralTypeSetInfos = new DbExpressionStructuralTypeEntitySetInfo();
                    var i = 0;
                    foreach (var info in argumentSetInfos.entitySetInfos)
                    {
                        structuralTypeSetInfos.Add(structuralType.Members[i].Name, info);
                        i++;
                    }
                    //Since we already validated the query view, the only association type that
                    //can be constructed is the type for the set we are validating the mapping for.
                    if (expression.ResultType.EdmType.BuiltInTypeKind
                        == BuiltInTypeKind.AssociationType)
                    {
                        ValidateEntitySetsMappedForAssociationSetMapping(structuralTypeSetInfos);
                    }
                    return(structuralTypeSetInfos);
                }
                return(null);
            }
Ejemplo n.º 3
0
            public override DbExpressionEntitySetInfo Visit(DbPropertyExpression expression)
            {
                DbExpressionStructuralTypeEntitySetInfo setInfos = VisitExpression(expression.Instance) as DbExpressionStructuralTypeEntitySetInfo;

                if (setInfos != null)
                {
                    return(setInfos.GetEntitySetInfoForMember(expression.Property.Name));
                }
                return(null);
            }