3
3
namespace System . Data . Entity . Core . Mapping
4
4
{
5
5
using System . Collections . Generic ;
6
+ using System . Collections . ObjectModel ;
6
7
using System . Data . Entity . Core . Common ;
7
8
using System . Data . Entity . Core . Common . CommandTrees ;
8
9
using System . Data . Entity . Core . Common . CommandTrees . ExpressionBuilder ;
@@ -11,6 +12,7 @@ namespace System.Data.Entity.Core.Mapping
11
12
using System . Data . Entity . Core . Metadata . Edm ;
12
13
using System . Data . Entity . Core . Query . InternalTrees ;
13
14
using System . Data . Entity . Core . Query . PlanCompiler ;
15
+ using System . Data . Entity . Resources ;
14
16
using System . Data . Entity . Utilities ;
15
17
using System . Diagnostics ;
16
18
using System . Diagnostics . CodeAnalysis ;
@@ -19,8 +21,46 @@ namespace System.Data.Entity.Core.Mapping
19
21
/// <summary>
20
22
/// Represents a mapping from a model function import to a store composable function.
21
23
/// </summary>
22
- internal class FunctionImportMappingComposable : FunctionImportMapping
24
+ public class FunctionImportMappingComposable : FunctionImportMapping
23
25
{
26
+ [ SuppressMessage ( "Microsoft.Design" , "CA1002:DoNotExposeGenericLists" ) ]
27
+ [ SuppressMessage ( "Microsoft.Design" , "CA1006:DoNotNestGenericTypesInMemberSignatures" ) ]
28
+ public FunctionImportMappingComposable (
29
+ EdmFunction functionImport ,
30
+ EdmFunction targetFunction ,
31
+ List < Tuple < StructuralType , List < StorageConditionPropertyMapping > , List < StoragePropertyMapping > > > structuralTypeMappings )
32
+ : base ( functionImport , targetFunction )
33
+ {
34
+ if ( ! functionImport . IsComposableAttribute )
35
+ {
36
+ throw new ArgumentException ( Strings . NonComposableFunctionCannotBeMappedAsComposable ( "functionImport" ) ) ;
37
+ }
38
+
39
+ if ( ! targetFunction . IsComposableAttribute )
40
+ {
41
+ throw new ArgumentException ( Strings . NonComposableFunctionCannotBeMappedAsComposable ( "targetFunction" ) ) ;
42
+ }
43
+
44
+ if ( functionImport . EntitySet != null )
45
+ {
46
+ throw new NotSupportedException ( Strings . ComposableFunctionImportsReturningEntitiesNotSupported ) ;
47
+ }
48
+
49
+ EdmType resultType ;
50
+ if ( ! MetadataHelper . TryGetFunctionImportReturnType ( functionImport , 0 , out resultType ) )
51
+ {
52
+ throw new ArgumentException ( Strings . InvalidReturnTypeForComposableFunction ) ;
53
+ }
54
+
55
+ if ( ! TypeSemantics . IsScalarType ( resultType )
56
+ && ( structuralTypeMappings == null || structuralTypeMappings . Count == 0 ) )
57
+ {
58
+ throw new ArgumentException ( Strings . StructuralTypeMappingsMustNotBeNullForFunctionImportsReturingNonScalarValues ) ;
59
+ }
60
+
61
+ m_structuralTypeMappings = structuralTypeMappings ;
62
+ }
63
+
24
64
internal FunctionImportMappingComposable (
25
65
EdmFunction functionImport ,
26
66
EdmFunction targetFunction ,
@@ -80,11 +120,18 @@ private readonly List<Tuple<StructuralType, List<StorageConditionPropertyMapping
80
120
/// </summary>
81
121
private Node m_internalTreeNode ;
82
122
123
+ [ SuppressMessage ( "Microsoft.Design" , "CA1006:DoNotNestGenericTypesInMemberSignatures" ) ]
124
+ public ReadOnlyCollection < Tuple < StructuralType , List < StorageConditionPropertyMapping > , List < StoragePropertyMapping > > > StructuralTypeMappings
125
+ {
126
+ get { return m_structuralTypeMappings == null ? null : m_structuralTypeMappings . AsReadOnly ( ) ; }
127
+ }
128
+
83
129
internal EdmProperty [ ] TvfKeys
84
130
{
85
131
get { return m_targetFunctionKeys ; }
86
132
}
87
133
134
+ [ SuppressMessage ( "Microsoft.Maintainability" , "CA1506:AvoidExcessiveClassCoupling" ) ]
88
135
[ SuppressMessage ( "Microsoft.Naming" , "CA2204:Literals should be spelled correctly" , MessageId = "projectOp" ) ]
89
136
[ SuppressMessage ( "Microsoft.Globalization" , "CA1303:Do not pass literals as localized parameters" ,
90
137
MessageId = "System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(System.Boolean,System.String)" ) ]
@@ -210,6 +257,8 @@ public override Node Visit(VarRefOp op, Node n)
210
257
211
258
internal DbQueryCommandTree GenerateFunctionView ( out DiscriminatorMap discriminatorMap )
212
259
{
260
+ DebugCheck . NotNull ( m_mappingItemCollection ) ;
261
+
213
262
discriminatorMap = null ;
214
263
215
264
// Prepare the direct call of the store function as StoreFunction(@EdmFunc_p1, ..., @EdmFunc_pN).
0 commit comments