:找不到“ microsoft.management.services.api.groupPolicyObjectFile”的IEdmType

时间:2019-07-01 17:42:16

标签: c# odata entity

我正在创建一个包含ODataActionParameter对象的动作。在创建模型构建器的地方,我想要接收我创建的实体所需的参数,但是会抛出“:”找不到“ Microsoft.management.services.api.groupPolicyObjectFile”的IEdmType。当参数是字符串类型时,它可以正常工作。有人以前见过这个IEdmType错误吗?

我已经为模型构建器尝试了entityparameter,collectionparameter和parameter。

public void Configure(IContext context, ODataConventionModelBuilder modelBuilder)
{
        context.IfNullThrow(nameof(context));
        modelBuilder.IfNullThrow(nameof(context));

        modelBuilder.EntityType<GroupPolicyObjectFile>();
        modelBuilder.EntityType<GroupPolicyMigrationReport>();
        modelBuilder.EntityType<GroupPolicySettingMapping>();

        modelBuilder.EntityType<DeviceManagement>().Action("analyzeGroupPolicyObjectFile").Parameter<GroupPolicyObjectFile>("groupPolicyObjectFile");

    }

这是我要使用的实体的声明:

[MinimumSupportedVersion(ServiceVersions.ExperimentalStart)]
[ODataDescription("The Group Policy Object file uploaded by admin.")]
[ODataCapabilities(supportsSkip: true, supportsTop: true)]
[GraphEntity(isMaster: true, AddressUrl = Constants.ServiceEndpoints.GPAnalyticsAdminService)]
[DataInventoryClass(Owner = Constants.Service.OwnerTeamAlias, DataStore = DataStore.DocDB, DataClassification = DataClassification.OII)]
public sealed class GroupPolicyObjectFile: GraphEntity

在这里采取行动:

[ODataRoute("analyzeGroupPolicyObjectFile")]     
[AuthorizeApplicationPermissionScopes(new string[] { DelegatedAppPermissionScopes.DeviceManagementConfiguration.ReadWriteAll }, new string[] { DelegatedAppPermissionScopes.DeviceManagementConfiguration.ReadWriteAll })]
[ODataParameterDescription("groupPolicyObjectFile", "Create group policy migration report")]
[HttpPost]
    public async Task<IHttpActionResult> AnalyzeGroupPolicyObjectFile(ODataActionParameters parameters)
    {

1 个答案:

答案 0 :(得分:0)

您需要使用EntityParameter代替Parameter作为实体参数:

modelBuilder.EntityType<DeviceManagement>().Action("analyzeGroupPolicyObjectFile").EntityParameter<GroupPolicyObjectFile>("groupPolicyObjectFile");

如果您需要实体集合作为参数,请使用CollectionEntityParameter

请参阅:http://odata.github.io/WebApi/#04-07-action-parameter-support