当前位置: 首页>>代码示例>>C#>>正文


C# EdmFunction类代码示例

本文整理汇总了C#中EdmFunction的典型用法代码示例。如果您正苦于以下问题:C# EdmFunction类的具体用法?C# EdmFunction怎么用?C# EdmFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EdmFunction类属于命名空间,在下文中一共展示了EdmFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_not_create_composable_function_import_mapping_with_entity_set_and_null_structural_type_mappings

        public void Can_not_create_composable_function_import_mapping_with_entity_set_and_null_structural_type_mappings()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var entitySet = new EntitySet("ES", null, null, null, entityType);

            var functionImport =
                new EdmFunction(
                    "f",
                    "entityModel",
                    DataSpace.CSpace,
                    new EdmFunctionPayload
                        {
                            IsComposable = true,
                            EntitySets = new[] { entitySet },
                            ReturnParameters =
                                new[]
                                    {
                                        new FunctionParameter(
                                            "ReturnType", 
                                            TypeUsage.CreateDefaultTypeUsage(entityType), 
                                            ParameterMode.ReturnValue)
                                    }
                        });

            Assert.Equal(
                Strings.ComposableFunctionImportsReturningEntitiesNotSupported,
                Assert.Throws<NotSupportedException>(
                    () => new FunctionImportMappingComposable(
                              functionImport,
                              new EdmFunction(
                              "f", "store", DataSpace.CSpace, new EdmFunctionPayload { IsComposable = true }),
                              null)).Message);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:33,代码来源:FunctionImportMappingComposableTests.cs

示例2: Cannot_create_with_null_argument

        public void Cannot_create_with_null_argument()
        {
            var entityType = new EntityType("ET", "N", DataSpace.CSpace);
            var entitySet = new EntitySet("ES", "S", "T", "Q", entityType);
            var function = new EdmFunction("F", "N", DataSpace.SSpace, new EdmFunctionPayload());
            var parameterBindings = Enumerable.Empty<ModificationFunctionParameterBinding>();
            var rowsAffectedParameter = new FunctionParameter("rows_affected", new TypeUsage(), ParameterMode.Out);
            var resultBindings = Enumerable.Empty<ModificationFunctionResultBinding>();

            Assert.Equal(
                "entitySet",
                Assert.Throws<ArgumentNullException>(
                    () => new ModificationFunctionMapping(
                        null, entityType, function, 
                        parameterBindings, rowsAffectedParameter, resultBindings)).ParamName);

            Assert.Equal(
                "function",
                Assert.Throws<ArgumentNullException>(
                    () => new ModificationFunctionMapping(
                        entitySet, entityType, null,
                        parameterBindings, rowsAffectedParameter, resultBindings)).ParamName);

            Assert.Equal(
                "parameterBindings",
                Assert.Throws<ArgumentNullException>(
                    () => new ModificationFunctionMapping(
                        entitySet, entityType, function,
                        null, rowsAffectedParameter, resultBindings)).ParamName);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:30,代码来源:ModificationFunctionMappingTests.cs

示例3: ReportFunctionOverloadError

        /// <summary>
        ///     Reports function overload resolution error.
        /// </summary>
        internal static void ReportFunctionOverloadError(MethodExpr functionExpr, EdmFunction functionType, List<TypeUsage> argTypes)
        {
            var strDelim = "";
            var sb = new StringBuilder();
            sb.Append(functionType.Name).Append("(");
            for (var i = 0; i < argTypes.Count; i++)
            {
                sb.Append(strDelim);
                sb.Append(argTypes[i] != null ? argTypes[i].EdmType.FullName : "NULL");
                strDelim = ", ";
            }
            sb.Append(")");

            Func<object, object, object, string> formatString;
            if (TypeSemantics.IsAggregateFunction(functionType))
            {
                formatString = TypeHelpers.IsCanonicalFunction(functionType)
                                   ? Strings.NoCanonicalAggrFunctionOverloadMatch
                                   : (Func<object, object, object, string>)Strings.NoAggrFunctionOverloadMatch;
            }
            else
            {
                formatString = TypeHelpers.IsCanonicalFunction(functionType)
                                   ? Strings.NoCanonicalFunctionOverloadMatch
                                   : (Func<object, object, object, string>)Strings.NoFunctionOverloadMatch;
            }

            throw EntitySqlException.Create(
                functionExpr.ErrCtx.CommandText,
                formatString(functionType.NamespaceName, functionType.Name, sb.ToString()),
                functionExpr.ErrCtx.InputPosition,
                Strings.CtxFunction(functionType.Name),
                false,
                null);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:38,代码来源:CqlErrorHelper.cs

示例4: StorageModificationFunctionMapping

        internal StorageModificationFunctionMapping(
            EntitySetBase entitySet,
            EntityTypeBase entityType,
            EdmFunction function,
            IEnumerable<StorageModificationFunctionParameterBinding> parameterBindings,
            FunctionParameter rowsAffectedParameter,
            IEnumerable<StorageModificationFunctionResultBinding> resultBindings)
        {
            DebugCheck.NotNull(entitySet);
            DebugCheck.NotNull(function);
            DebugCheck.NotNull(parameterBindings);

            _function = function;
            _rowsAffectedParameter = rowsAffectedParameter;

            ParameterBindings = parameterBindings.ToList().AsReadOnly();

            if (null != resultBindings)
            {
                var bindings = resultBindings.ToList();

                if (0 < bindings.Count)
                {
                    ResultBindings = bindings.AsReadOnly();
                }
            }

            CollocatedAssociationSetEnds =
                GetReferencedAssociationSetEnds(entitySet as EntitySet, entityType as EntityType, parameterBindings)
                    .ToList()
                    .AsReadOnly();
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:32,代码来源:StorageModificationFunctionMapping.cs

示例5: ReportFunctionOverloadError

        /// <summary>
        /// Reports function overload resolution error.
        /// </summary>
        internal static void ReportFunctionOverloadError(AST.MethodExpr functionExpr, EdmFunction functionType, List<TypeUsage> argTypes)
        {
            string strDelim = "";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(functionType.Name).Append("(");
            for (int i = 0 ; i < argTypes.Count ; i++)
            {
                sb.Append(strDelim);
                sb.Append(argTypes[i] != null ? argTypes[i].EdmType.FullName : "NULL");
                strDelim = ", ";
            }
            sb.Append(")");

            Func<object, object, object, string> formatString;
            if (TypeSemantics.IsAggregateFunction(functionType))
            {
                formatString = TypeHelpers.IsCanonicalFunction(functionType) ? 
                                            (Func<object, object, object, string>)System.Data.Entity.Strings.NoCanonicalAggrFunctionOverloadMatch :
                                            (Func<object, object, object, string>)System.Data.Entity.Strings.NoAggrFunctionOverloadMatch;
            }
            else
            {
                formatString = TypeHelpers.IsCanonicalFunction(functionType) ?
                                            (Func<object, object, object, string>)System.Data.Entity.Strings.NoCanonicalFunctionOverloadMatch :
                                            (Func<object, object, object, string>)System.Data.Entity.Strings.NoFunctionOverloadMatch;
            }

            throw EntityUtil.EntitySqlError(functionExpr.ErrCtx.CommandText,
                                 formatString(functionType.NamespaceName, functionType.Name, sb.ToString()),
                                 functionExpr.ErrCtx.InputPosition,
                                 System.Data.Entity.Strings.CtxFunction(functionType.Name),
                                 false /* loadContextInfoFromResource */);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:36,代码来源:CqlErrorHelper.cs

示例6: FunctionImportMappingNonComposable

        internal FunctionImportMappingNonComposable(
            EdmFunction functionImport,
            EdmFunction targetFunction,
            List<List<FunctionImportStructuralTypeMapping>> structuralTypeMappingsList,
            ItemCollection itemCollection)
            : base(functionImport, targetFunction)
        {
            //Contract.Requires(structuralTypeMappingsList != null);
            //Contract.Requires(itemCollection != null);
            Debug.Assert(!functionImport.IsComposableAttribute, "!functionImport.IsComposableAttribute");
            Debug.Assert(!targetFunction.IsComposableAttribute, "!targetFunction.IsComposableAttribute");

            if (structuralTypeMappingsList.Count == 0)
            {
                ResultMappings = new OM.ReadOnlyCollection<FunctionImportStructuralTypeMappingKB>(
                    new[]
                        {
                            new FunctionImportStructuralTypeMappingKB(new List<FunctionImportStructuralTypeMapping>(), itemCollection)
                        });
                noExplicitResultMappings = true;
            }
            else
            {
                Debug.Assert(functionImport.ReturnParameters.Count == structuralTypeMappingsList.Count);
                ResultMappings = new OM.ReadOnlyCollection<FunctionImportStructuralTypeMappingKB>(
                    structuralTypeMappingsList
                        .Select(
                            (structuralTypeMappings) => new FunctionImportStructuralTypeMappingKB(
                                                            structuralTypeMappings,
                                                            itemCollection))
                        .ToArray());
                noExplicitResultMappings = false;
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:34,代码来源:FunctionImportMappingNonComposable.cs

示例7: Can_clear_modification_function_mappings

        public void Can_clear_modification_function_mappings()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var entitySet = new EntitySet("S", "N", null, null, entityType);
            var function = new EdmFunction("F", "N", DataSpace.SSpace, new EdmFunctionPayload());

            var container = new EntityContainer("C", DataSpace.CSpace);
            container.AddEntitySetBase(entitySet);

            var entitySetMapping =
                new StorageEntitySetMapping(
                    entitySet,
                    new StorageEntityContainerMapping(container));

            var functionMapping =
                new StorageModificationFunctionMapping(
                    entitySet,
                    entityType,
                    function,
                    Enumerable.Empty<StorageModificationFunctionParameterBinding>(),
                    null,
                    null);

            var entityFunctionMappings =
                new StorageEntityTypeModificationFunctionMapping(entityType, functionMapping, null, null);

            entitySetMapping.AddModificationFunctionMapping(entityFunctionMappings);

            Assert.Equal(1, entitySetMapping.ModificationFunctionMappings.Count());

            entitySetMapping.ClearModificationFunctionMappings();

            Assert.Equal(0, entitySetMapping.ModificationFunctionMappings.Count());
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:34,代码来源:StorageEntitySetMappingTests.cs

示例8: StorageModificationFunctionMapping

        internal StorageModificationFunctionMapping(
            EntitySetBase entitySet,
            EntityTypeBase entityType,
            EdmFunction function,
            IEnumerable<StorageModificationFunctionParameterBinding> parameterBindings,
            FunctionParameter rowsAffectedParameter,
            IEnumerable<StorageModificationFunctionResultBinding> resultBindings)
        {
            //Contract.Requires(entitySet != null);
            //Contract.Requires(function != null);
            //Contract.Requires(parameterBindings != null);

            Function = function;
            RowsAffectedParameter = rowsAffectedParameter;
            ParameterBindings = parameterBindings.ToList().AsReadOnly();
            if (null != resultBindings)
            {
                var bindings = resultBindings.ToList();
                if (0 < bindings.Count)
                {
                    ResultBindings = bindings.AsReadOnly();
                }
            }
            CollocatedAssociationSetEnds =
                GetReferencedAssociationSetEnds(entitySet as EntitySet, entityType as EntityType, parameterBindings)
                    .ToList()
                    .AsReadOnly();
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:28,代码来源:StorageModificationFunctionMapping.cs

示例9: FunctionImportMappingNonComposable

        internal FunctionImportMappingNonComposable(
            EdmFunction functionImport,
            EdmFunction targetFunction,
            List<List<FunctionImportStructuralTypeMapping>> structuralTypeMappingsList,
            ItemCollection itemCollection)
            : base(functionImport, targetFunction)
        {
            EntityUtil.CheckArgumentNull(structuralTypeMappingsList, "structuralTypeMappingsList");
            EntityUtil.CheckArgumentNull(itemCollection, "itemCollection");
            Debug.Assert(!functionImport.IsComposableAttribute, "!functionImport.IsComposableAttribute");
            Debug.Assert(!targetFunction.IsComposableAttribute, "!targetFunction.IsComposableAttribute");

            if (structuralTypeMappingsList.Count == 0)
            {
                this.ResultMappings = new OM.ReadOnlyCollection<FunctionImportStructuralTypeMappingKB>(
                    new FunctionImportStructuralTypeMappingKB[] { 
                        new FunctionImportStructuralTypeMappingKB(new List<FunctionImportStructuralTypeMapping>(), itemCollection) });
                this.noExplicitResultMappings = true;
            }
            else
            {
                Debug.Assert(functionImport.ReturnParameters.Count == structuralTypeMappingsList.Count);
                this.ResultMappings = new OM.ReadOnlyCollection<FunctionImportStructuralTypeMappingKB>(
                    EntityUtil.CheckArgumentNull(structuralTypeMappingsList, "structuralTypeMappingsList")
                        .Select((structuralTypeMappings) => new FunctionImportStructuralTypeMappingKB(
                            EntityUtil.CheckArgumentNull(structuralTypeMappings, "structuralTypeMappings"),
                            itemCollection))
                        .ToArray());
                this.noExplicitResultMappings = false;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:31,代码来源:FunctionImportMappingNonComposable.cs

示例10: FunctionImportMappingComposable

        internal FunctionImportMappingComposable(
            EdmFunction functionImport,
            EdmFunction targetFunction,
            List<Tuple<StructuralType, List<StorageConditionPropertyMapping>, List<StoragePropertyMapping>>> structuralTypeMappings,
            EdmProperty[] targetFunctionKeys,
            StorageMappingItemCollection mappingItemCollection,
            string sourceLocation,
            LineInfo lineInfo) 
            : base(functionImport, targetFunction)
        {
            EntityUtil.CheckArgumentNull(mappingItemCollection, "mappingItemCollection");
            Debug.Assert(functionImport.IsComposableAttribute, "functionImport.IsComposableAttribute");
            Debug.Assert(targetFunction.IsComposableAttribute, "targetFunction.IsComposableAttribute");
            Debug.Assert(functionImport.EntitySet == null || structuralTypeMappings != null, "Function import returning entities must have structuralTypeMappings.");
            Debug.Assert(structuralTypeMappings == null || structuralTypeMappings.Count > 0, "Non-null structuralTypeMappings must not be empty.");
            EdmType resultType;
            Debug.Assert(
                structuralTypeMappings != null ||
                MetadataHelper.TryGetFunctionImportReturnType<EdmType>(functionImport, 0, out resultType) && TypeSemantics.IsScalarType(resultType),
                "Either type mappings should be specified or the function import should be Collection(Scalar).");
            Debug.Assert(functionImport.EntitySet == null || targetFunctionKeys != null, "Keys must be inferred for a function import returning entities.");
            Debug.Assert(targetFunctionKeys == null || targetFunctionKeys.Length > 0, "Keys must be null or non-empty.");

            m_mappingItemCollection = mappingItemCollection;
            // We will use these parameters to target s-space function calls in the generated command tree. 
            // Since enums don't exist in s-space we need to use the underlying type.
            m_commandParameters = functionImport.Parameters.Select(p => TypeHelpers.GetPrimitiveTypeUsageForScalar(p.TypeUsage).Parameter(p.Name)).ToArray();
            m_structuralTypeMappings = structuralTypeMappings;
            m_targetFunctionKeys = targetFunctionKeys;
            m_sourceLocation = sourceLocation;
            m_lineInfo = lineInfo;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:32,代码来源:FunctionImportMappingComposable.cs

示例11: ModificationFunctionMapping

        /// <summary>
        /// Initializes a new ModificationFunctionMapping instance.
        /// </summary>
        /// <param name="entitySet">The entity or association set.</param>
        /// <param name="entityType">The entity or association type.</param>
        /// <param name="function">The metadata of function to which we should bind.</param>
        /// <param name="parameterBindings">Bindings for function parameters.</param>
        /// <param name="rowsAffectedParameter">The output parameter producing number of rows affected.</param>
        /// <param name="resultBindings">Bindings for the results of function evaluation</param>
        public ModificationFunctionMapping(
            EntitySetBase entitySet,
            EntityTypeBase entityType,
            EdmFunction function,
            IEnumerable<ModificationFunctionParameterBinding> parameterBindings,
            FunctionParameter rowsAffectedParameter,
            IEnumerable<ModificationFunctionResultBinding> resultBindings)
        {
            Check.NotNull(entitySet, "entitySet");
            Check.NotNull(function, "function");
            Check.NotNull(parameterBindings, "parameterBindings");

            _function = function;
            _rowsAffectedParameter = rowsAffectedParameter;

            _parameterBindings = new ReadOnlyCollection<ModificationFunctionParameterBinding>(parameterBindings.ToList());

            if (null != resultBindings)
            {
                var bindings = resultBindings.ToList();

                if (0 < bindings.Count)
                {
                    _resultBindings = new ReadOnlyCollection<ModificationFunctionResultBinding>(bindings);
                }
            }

            _collocatedAssociationSetEnds =
                new ReadOnlyCollection<AssociationSetEnd>(
                    GetReferencedAssociationSetEnds(entitySet as EntitySet, entityType as EntityType, parameterBindings)
                        .ToList());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:41,代码来源:ModificationFunctionMapping.cs

示例12: AddAggregate

        internal void AddAggregate(
            PrimitiveTypeKind returnTypeKind, string aggregateFunctionName, PrimitiveTypeKind collectionArgumentElementTypeKind)
        {
            DebugCheck.NotEmpty(aggregateFunctionName);

            var returnParameter = CreateReturnParameter(returnTypeKind);
            var collectionParameter = CreateAggregateParameter(collectionArgumentElementTypeKind);

            var function = new EdmFunction(
                aggregateFunctionName,
                EdmConstants.EdmNamespace,
                DataSpace.CSpace,
                new EdmFunctionPayload
                    {
                        IsAggregate = true,
                        IsBuiltIn = true,
                        ReturnParameters = new[] { returnParameter },
                        Parameters = new FunctionParameter[1] { collectionParameter },
                        IsFromProviderManifest = true,
                    });

            function.SetReadOnly();

            functions.Add(function);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:25,代码来源:EdmProviderManifestFunctionBuilder.cs

示例13: WriteFunctionElementHeader_should_not_write_return_type_attribute_for_non_primitive_return_type

        public void WriteFunctionElementHeader_should_not_write_return_type_attribute_for_non_primitive_return_type()
        {
            var fixture = new Fixture();

            var returnParameterType = TypeUsage.CreateDefaultTypeUsage(new RowType());

            var function = new EdmFunction(
                "Foo",
                "Bar",
                DataSpace.SSpace,
                new EdmFunctionPayload
                    {
                        Schema = "dbo",
                        ReturnParameters =
                            new[]
                                {
                                    new FunctionParameter(
                                        "r",
                                        returnParameterType,
                                        ParameterMode.ReturnValue)
                                }
                    });

            fixture.Writer.WriteFunctionElementHeader(function);

            Assert.Equal(
                "<Function Name=\"Foo\" Aggregate=\"false\" BuiltIn=\"false\" NiladicFunction=\"false\" IsComposable=\"true\" ParameterTypeSemantics=\"AllowImplicitConversion\" Schema=\"dbo\"",
                fixture.ToString());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:29,代码来源:EdmXmlSchemaWriterTests.cs

示例14: FunctionImportMappingComposable

        public FunctionImportMappingComposable(
            EdmFunction functionImport,
            EdmFunction targetFunction,
            List<Tuple<StructuralType, List<StorageConditionPropertyMapping>, List<StoragePropertyMapping>>> structuralTypeMappings)
            : base(functionImport, targetFunction)
        {
            if (!functionImport.IsComposableAttribute)
            {
                throw new ArgumentException(Strings.NonComposableFunctionCannotBeMappedAsComposable("functionImport"));
            }

            if (!targetFunction.IsComposableAttribute)
            {
                throw new ArgumentException(Strings.NonComposableFunctionCannotBeMappedAsComposable("targetFunction"));
            }

            if (functionImport.EntitySet != null)
            {
                throw new NotSupportedException(Strings.ComposableFunctionImportsReturningEntitiesNotSupported);
            }

            EdmType resultType;
            if (!MetadataHelper.TryGetFunctionImportReturnType(functionImport, 0, out resultType))
            {
                throw new ArgumentException(Strings.InvalidReturnTypeForComposableFunction);
            }

            if (!TypeSemantics.IsScalarType(resultType)
                && (structuralTypeMappings == null || structuralTypeMappings.Count == 0))
            {
                throw new ArgumentException(Strings.StructuralTypeMappingsMustNotBeNullForFunctionImportsReturingNonScalarValues);
            }

            m_structuralTypeMappings = structuralTypeMappings;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:35,代码来源:FunctionImportMappingComposable.cs

示例15: DbFunctionAggregate

        internal DbFunctionAggregate(TypeUsage resultType, DbExpressionList arguments, EdmFunction function, bool isDistinct)
            : base(resultType, arguments)
        {
            DebugCheck.NotNull(function);

            _aggregateFunction = function;
            _distinct = isDistinct;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:8,代码来源:DbFunctionAggregate.cs


注:本文中的EdmFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。