I am strugging with using an anonymous type in Azure Cosmos Linq syntax. This is the SQL I am trying to emit:
// @"SELECT c.Profile.Customer.CompanyName,
// c.Profile.Customer.CustomerID,
// c.CustomFields.Status
// FROM c"
// );
My Linq query looks like this but will not compile because the anonymous type doesn't match the type of the IQueryable
IQueryable<CustomerDocument> query = container.GetItemLinqQueryable<CustomerDocument>()
.Select(c => new
{
c.Profile.Customer.CompanyName,
c.Profile.Customer.CustomerID,
c.CustomFields.Status
}).ToFeedIterator<CustomerDocument>();
If I omit the anonymous type the query runs fine, but it emits SELECT * FROM c which is very slow due to the size of the schema in the container. If I run the SQL statement it is very fast, but obviously I don't want to maintain SQL text in my code if I can avoid it.
Any ideas what I am doing wrong here? Not using Entity Framework in this project.