If I want to return an object based on a Interface in CosmoDb how would I do it? My Interface:
namespace Test
{
public interface IPerson
{
int Age { get; set; }
}
public class Person : IPerson
{
public int Age { get; set; }
}
}
My CosmosDb method:
public async Task<IPerson> FleetUpdate(IPerson person)
try
{
var res = await docClient.UpsertDocumentAsync(UriFactory.CreateDocumentCollectionUri(dbname, colName), person);
IPerson person = (dynamic)res.Resource;
return person;
}
catch (Exception ex)
{
throw ex;
}
I am getting an error:
Unable to cast object of type 'Microsoft.Azure.Documents.Document' to type 'CabbyTech.FleetOps.Classes.IFleet'.
How should I cast the response to a Person or IPerson?