-
Notifications
You must be signed in to change notification settings - Fork 27
Issue #1 - modified GetModelParametersForModelDefinedFunction to take… #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -492,7 +492,7 @@ private static IList<FunctionParameter> GetStoreReturnParameters( | |
| if (modelReturnParameterComplexType != null) | ||
| { | ||
| storeReturnParameterRowType = RowType.Create( | ||
| modelReturnParameterComplexType.Properties.Select(property => | ||
| modelReturnParameterComplexType.Properties.Select(property => | ||
| EdmProperty.Create(property.Name, model.ProviderManifest.GetStoreType(property.TypeUsage))), | ||
| null); | ||
| } | ||
|
|
@@ -557,12 +557,34 @@ private static IList<FunctionParameter> GetModelParametersForModelDefinedFunctio | |
| this DbModel model, MethodInfo methodInfo) | ||
| { | ||
| ParameterInfo[] parameters = methodInfo.GetParameters().ToArray(); | ||
| return parameters | ||
| .Select((parameterInfo) => FunctionParameter.Create( | ||
| parameterInfo.GetCustomAttribute<ParameterAttribute>()?.Name ?? parameterInfo.Name, | ||
| model.GetModelStructualType(parameterInfo.ParameterType, methodInfo), | ||
| ParameterMode.In)) | ||
| .ToArray(); | ||
| return parameters.Select( | ||
| (parameterInfo) => | ||
| { | ||
| EdmType type = model.GetModelPrimitiveType(parameterInfo.ParameterType, methodInfo); | ||
| if (type == null) | ||
| { | ||
| type = model.GetModelComplexType(parameterInfo.ParameterType, methodInfo); | ||
| if (type == null) | ||
| { | ||
| type = model.GetModelEntityType(parameterInfo.ParameterType, methodInfo); | ||
| if (type == null) | ||
| { | ||
| type = model.GetModelStructualType(parameterInfo.ParameterType, methodInfo); | ||
| if (type == null) | ||
| { | ||
| throw new NotSupportedException( | ||
| $"{parameterInfo.ParameterType.FullName} for method {methodInfo.Name} is " | ||
| + "not supported in conceptual model"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work: EdmType type; |
||
| return FunctionParameter.Create(parameterInfo.GetCustomAttribute<ParameterAttribute>()?.Name ?? parameterInfo.Name, | ||
| type, | ||
| ParameterMode.In); | ||
| } | ||
| ).ToArray(); | ||
| } | ||
|
|
||
| private static IList<FunctionParameter> GetModelReturnParameters( | ||
|
|
@@ -694,11 +716,11 @@ private static PrimitiveType GetModelPrimitiveType(this DbModel model, Type clrT | |
| PrimitiveType modelPrimitiveType = PrimitiveType | ||
| .GetEdmPrimitiveTypes() | ||
| .FirstOrDefault(primitiveType => primitiveType.ClrEquivalentType == clrType); | ||
| if (modelPrimitiveType == null) | ||
| { | ||
| throw new NotSupportedException( | ||
| $"Type {nameof(clrType.FullName)} in method {methodInfo.Name} is not supported in conceptual model."); | ||
| } | ||
| //if (modelPrimitiveType == null) | ||
| //{ | ||
| // throw new NotSupportedException( | ||
| // $"Type {nameof(clrType.FullName)} in method {methodInfo.Name} is not supported in conceptual model."); | ||
| //} | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed. See comment above. |
||
| return modelPrimitiveType; | ||
| } | ||
|
|
@@ -717,8 +739,10 @@ private static StructuralType GetModelStructualType(this DbModel model, Type clr | |
| return complexType; | ||
| } | ||
|
|
||
| throw new NotSupportedException( | ||
| $"{clrType.FullName} for method {methodInfo.Name} is not supported in conceptual model as a structural type."); | ||
| return default(StructuralType); | ||
|
|
||
| //throw new NotSupportedException( | ||
| // $"{clrType.FullName} for method {methodInfo.Name} is not supported in conceptual model as a structural type."); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed. See comment above. |
||
| } | ||
|
|
||
| private static EntityType GetModelEntityType(this DbModel model, Type clrType, MethodInfo methodInfo) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model.GetModelStructualType calls model.GetModelComplexType and model.GetModelEntityType internally, and throw NotSupportedException.