Пример #1
0
        internal DbQueryCommandTree GetCommandTree()
        {
            Exception parserException;

            if (this.m_commandTree == null && !GeneratedView.TryParseView(this.m_eSQL, false, this.m_extent, this.m_mappingItemCollection, this.m_config, out this.m_commandTree, out this.m_discriminatorMap, out parserException))
            {
                throw new MappingException(Strings.Mapping_Invalid_QueryView((object)this.m_extent.Name, (object)parserException.Message));
            }
            return(this.m_commandTree);
        }
Пример #2
0
        internal static bool TryParseUserSpecifiedView(
            EntitySetBaseMapping setMapping,
            EntityTypeBase type,
            string eSQL,
            bool includeSubtypes,
            StorageMappingItemCollection mappingItemCollection,
            ConfigViewGenerator config,
            IList <EdmSchemaError> errors,
            out GeneratedView generatedView)
        {
            bool flag = false;
            DbQueryCommandTree commandTree;
            DiscriminatorMap   discriminatorMap;
            Exception          parserException;

            if (!GeneratedView.TryParseView(eSQL, true, setMapping.Set, mappingItemCollection, config, out commandTree, out discriminatorMap, out parserException))
            {
                EdmSchemaError edmSchemaError = new EdmSchemaError(Strings.Mapping_Invalid_QueryView2((object)setMapping.Set.Name, (object)parserException.Message), 2068, EdmSchemaErrorSeverity.Error, setMapping.EntityContainerMapping.SourceLocation, setMapping.StartLineNumber, setMapping.StartLinePosition, parserException);
                errors.Add(edmSchemaError);
                flag = true;
            }
            else
            {
                foreach (EdmSchemaError edmSchemaError in ViewValidator.ValidateQueryView(commandTree, setMapping, type, includeSubtypes))
                {
                    errors.Add(edmSchemaError);
                    flag = true;
                }
                CollectionType edmType = commandTree.Query.ResultType.EdmType as CollectionType;
                if (edmType == null || !setMapping.Set.ElementType.IsAssignableFrom(edmType.TypeUsage.EdmType))
                {
                    EdmSchemaError edmSchemaError = new EdmSchemaError(Strings.Mapping_Invalid_QueryView_Type((object)setMapping.Set.Name), 2069, EdmSchemaErrorSeverity.Error, setMapping.EntityContainerMapping.SourceLocation, setMapping.StartLineNumber, setMapping.StartLinePosition);
                    errors.Add(edmSchemaError);
                    flag = true;
                }
            }
            if (!flag)
            {
                generatedView = new GeneratedView(setMapping.Set, (EdmType)type, commandTree, eSQL, discriminatorMap, mappingItemCollection, config);
                return(true);
            }
            generatedView = (GeneratedView)null;
            return(false);
        }