Loading...

Iterate through Response>>$"{_applicationUris.GranularKVInfo}/{_KVlId}/kv");


I am trying to iterate through a variable which is set through a response and filter it. I want to filter based on contact type. Is this possible? any suggestions are welcome.

//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();
}
- - Source

Answers

answered 1 week ago Derviş Kayımbaşıoğlu #1

You can use

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

comments powered by Disqus