遍历Response <list> <kvinfomodel >>> $“ {_ applicationUris.GranularKVInfo} / {_ KVlId} / kv”);

时间:2019-03-14 21:52:01

标签: c# list asp.net-web-api microservices

我试图遍历通过响应设置的变量并对其进行过滤。我想根据联系人类型进行过滤。这可能吗?欢迎任何建议。

//Response class

    public class Response<T> : Response
        {
            public Response();

            public T Content { get; set; }
        }

private async Task<string> GetKVValueAsync()
        {
     var KVContactInformation = await _restServiceClient.GetAsync<Response<List<KVInfoModel>>>($"{_applicationUris.GranularKVInfo}/{_KVlId}/kv");

                List<KVInfoModel> TestList = new List<KVInfoModel>();

                TestList = KVContactInformation.Where(Xyz => xyz.contactType == "Sample");

                return TestList();
}

1 个答案:

答案 0 :(得分:0)

您可以使用

var KVContactInformation = await _restServiceClient.GetAsync<Response<List<KVInfoModel>>>($"{_applicationUris.GranularKVInfo}/{_KVlId}/kv"); 
List<KVInfoModel> testList = KVContactInformation.Content.Where(Xyz => xyz.contactType == "Sample");
return testList;