コード例 #1
0
        private void AddDefaultConstants(List <QueryScalarValue> scalarValues, QueryTypeLibrary queryTypeLibrary)
        {
            var intType    = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Int32);
            var stringType = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.String());
            var boolType   = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Boolean);

            scalarValues.Add(intType.CreateValue(1));
            scalarValues.Add(stringType.CreateValue("Foo"));
            scalarValues.Add(boolType.CreateValue(true));
            scalarValues.Add(boolType.CreateValue(false));
        }
コード例 #2
0
        /// <summary>
        /// Override the default method, adding generation of root queries that call designated service operations
        /// </summary>
        /// <param name="entityModelSchema">Entity Model Schema</param>
        /// <param name="queryTypeLibrary">Query Type Library</param>
        protected override void BuildRootQueriesAndTypes(EntityModelSchema entityModelSchema, QueryTypeLibrary queryTypeLibrary)
        {
            base.BuildRootQueriesAndTypes(entityModelSchema, queryTypeLibrary);

            // For each service operation marked as root, add a root query that calls the operation
            var rootServiceOperationQueries = new List <QueryExpression>();

            foreach (var serviceOperation in entityModelSchema.Functions.Where(f => f.Annotations.OfType <FunctionBodyAnnotation>().Any(a => a.IsRoot)))
            {
                QueryExpression bodyExpression = serviceOperation.Annotations.OfType <FunctionBodyAnnotation>().Single().FunctionBody;
                ExceptionUtilities.CheckObjectNotNull(bodyExpression, "Root level function has null body expression");

                QueryType rootQueryType = queryTypeLibrary.GetDefaultQueryType(serviceOperation.ReturnType);
                var       rootQuery     = new QueryCustomFunctionCallExpression(rootQueryType, serviceOperation, bodyExpression, true, false);
                rootServiceOperationQueries.Add(rootQuery);

                QueryStructuralType structuralType = rootQueryType as QueryStructuralType;
                if (structuralType == null)
                {
                    QueryCollectionType collectionType = rootQueryType as QueryCollectionType;
                    if (collectionType != null)
                    {
                        structuralType = collectionType.ElementType as QueryStructuralType;
                    }
                }

                ExceptionUtilities.CheckObjectNotNull(structuralType, "Root level service op query must return structural type");
                this.RootDataTypes.Add(serviceOperation.Name, structuralType);
            }

            this.RootQueries = this.RootQueries.Concat(rootServiceOperationQueries);
        }
コード例 #3
0
        /// <summary>
        /// Build the collection of primitive types which will be set on the constructed repository
        /// </summary>
        /// <param name="queryTypeLibrary">Query Type Library to build Types from</param>
        protected override void BuildPrimitiveTypes(QueryTypeLibrary queryTypeLibrary)
        {
            this.intType = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Int32);
            this.stringType = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.String());

            this.PrimitiveTypes = new List<QueryScalarType>()
            {
                // this is just a sample
                this.intType,
                this.stringType,
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Boolean),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.DateTime()),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Decimal()),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Int64),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Int16),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Byte),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Single),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Double),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Binary()),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Guid),
            };
        }
コード例 #4
0
        private void AddDefaultConstants(List<QueryScalarValue> scalarValues, QueryTypeLibrary queryTypeLibrary)
        {
            var intType = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Int32);
            var stringType = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.String());
            var boolType = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Boolean);

            scalarValues.Add(intType.CreateValue(1));
            scalarValues.Add(stringType.CreateValue("Foo"));
            scalarValues.Add(boolType.CreateValue(true));
            scalarValues.Add(boolType.CreateValue(false));
        }
コード例 #5
0
        /// <summary>
        /// Override the default method, adding generation of root queries that call designated service operations
        /// </summary>
        /// <param name="entityModelSchema">Entity Model Schema</param>
        /// <param name="queryTypeLibrary">Query Type Library</param>
        protected override void BuildRootQueriesAndTypes(EntityModelSchema entityModelSchema, QueryTypeLibrary queryTypeLibrary)
        {
            base.BuildRootQueriesAndTypes(entityModelSchema, queryTypeLibrary);

            // For each service operation marked as root, add a root query that calls the operation
            var rootServiceOperationQueries = new List<QueryExpression>();
            foreach (var serviceOperation in entityModelSchema.Functions.Where(f => f.Annotations.OfType<FunctionBodyAnnotation>().Any(a => a.IsRoot)))
            {
                QueryExpression bodyExpression = serviceOperation.Annotations.OfType<FunctionBodyAnnotation>().Single().FunctionBody;
                ExceptionUtilities.CheckObjectNotNull(bodyExpression, "Root level function has null body expression");

                QueryType rootQueryType = queryTypeLibrary.GetDefaultQueryType(serviceOperation.ReturnType);
                var rootQuery = new QueryCustomFunctionCallExpression(rootQueryType, serviceOperation, bodyExpression, true, false);
                rootServiceOperationQueries.Add(rootQuery);

                QueryStructuralType structuralType = rootQueryType as QueryStructuralType;
                if (structuralType == null)
                {
                    QueryCollectionType collectionType = rootQueryType as QueryCollectionType;
                    if (collectionType != null)
                    {
                        structuralType = collectionType.ElementType as QueryStructuralType;
                    }
                }

                ExceptionUtilities.CheckObjectNotNull(structuralType, "Root level service op query must return structural type");
                this.RootDataTypes.Add(serviceOperation.Name, structuralType);
            }

            this.RootQueries = this.RootQueries.Concat(rootServiceOperationQueries);
        }
コード例 #6
0
        /// <summary>
        /// Build the collection of primitive types which will be set on the constructed repository
        /// </summary>
        /// <param name="queryTypeLibrary">Query Type Library to build Types from</param>
        protected override void BuildPrimitiveTypes(QueryTypeLibrary queryTypeLibrary)
        {
            this.intType    = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Int32);
            this.stringType = (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.String());

            this.PrimitiveTypes = new List <QueryScalarType>()
            {
                // this is just a sample
                this.intType,
                this.stringType,
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Boolean),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.DateTime()),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Decimal()),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Int64),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Int16),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Byte),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Single),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Double),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Binary()),
                (QueryScalarType)queryTypeLibrary.GetDefaultQueryType(EdmDataTypes.Guid),
            };
        }
コード例 #7
0
 /// <summary>
 /// Get the query type for a scalar property (with mapped store semantics, if applicable)
 /// </summary>
 /// <param name="pathToProperty">The path to find the property</param>
 /// <param name="library">The query type library</param>
 /// <param name="modelType">The model data type for the property</param>
 /// <returns>The query scalar type for the property</returns>
 /// <remarks>Default implementation just returns default type (meaning no special store semantics from mapping). Derived class should override as appropriate.</remarks>
 protected virtual QueryScalarType GetQueryTypeForMappedProperty(PathToProperty pathToProperty, QueryTypeLibrary library, PrimitiveDataType modelType)
 {
     return (QueryScalarType)library.GetDefaultQueryType(modelType);
 }
コード例 #8
0
 /// <summary>
 /// Get the query type for a scalar property (with mapped store semantics, if applicable)
 /// </summary>
 /// <param name="pathToProperty">The path to find the property</param>
 /// <param name="library">The query type library</param>
 /// <param name="modelType">The model data type for the property</param>
 /// <returns>The query scalar type for the property</returns>
 /// <remarks>Default implementation just returns default type (meaning no special store semantics from mapping). Derived class should override as appropriate.</remarks>
 protected virtual QueryScalarType GetQueryTypeForMappedProperty(PathToProperty pathToProperty, QueryTypeLibrary library, PrimitiveDataType modelType)
 {
     return((QueryScalarType)library.GetDefaultQueryType(modelType));
 }