Skip to content

Commit

Permalink
Use fixed conversion of FetchXML to Web API for entity name attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Jul 20, 2022
1 parent 34a96ac commit 29d9e6a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions FetchXmlBuilder/AppCode/WebAPIMetadataProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MarkMpn.FetchXmlToWebAPI;
using Microsoft.Xrm.Sdk.Metadata;
using System;
using System.Linq;

namespace Rappen.XTB.FetchXmlBuilder.AppCode
{
Expand Down Expand Up @@ -29,5 +30,22 @@ public EntityMetadata GetEntity(string logicalName)

return metadata;
}

public EntityMetadata GetEntity(int otc)
{
if (fetchXmlBuilder.entities == null)
{
throw new Exception("Metadata not loaded");
}

var entity = fetchXmlBuilder.entities.SingleOrDefault(e => e.ObjectTypeCode == otc);

if (entity == null)
{
throw new Exception($"No metadata for entity: {otc}");
}

return GetEntity(entity.LogicalName);
}
}
}

0 comments on commit 29d9e6a

Please sign in to comment.