Wednesday 19 September 2018

Error while generating proxy class for OData .net client



In the ODataClient.ttinclude file, Go to the line no: 2681.
You can find an else part
Replace the else part with the below code:
else
{
clrTypeName = "caughtExceptionName";
try
{
IEdmCollectionType edmCollectionType = (IEdmCollectionType)edmType;
IEdmTypeReference elementTypeReference = edmCollectionType.ElementType;
IEdmPrimitiveType primitiveElementType = elementTypeReference.Definition as IEdmPrimitiveType;
if (primitiveElementType != null)
{
clrTypeName = Utils.GetClrTypeName(primitiveElementType, clientTemplate);
}
else
{
IEdmSchemaElement schemaElement = (IEdmSchemaElement)elementTypeReference.Definition;
clrTypeName = context.GetPrefixedFullName(schemaElement,
context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(schemaElement.Name)) :
clientTemplate.GetFixedName(schemaElement.Name), clientTemplate);
}
string collectionTypeName = isOperationParameter
? clientTemplate.ICollectionOfTStructureTemplate
: (useDataServiceCollection
? (elementTypeReference.TypeKind() == EdmTypeKind.Entity
? clientTemplate.DataServiceCollectionStructureTemplate
: clientTemplate.ObservableCollectionStructureTemplate)
: clientTemplate.ObjectModelCollectionStructureTemplate);
clrTypeName = string.Format(collectionTypeName, clrTypeName);
}
catch(Exception ex)
{
}
}
Now generate the OData file, The OData will be generated but you will be facing around 6 errors
Comment the methods where you are facing the error till the solution build successfully.
Once the solution build successfully you can use the OData class file.

No comments:

Post a Comment