I have a DocumentDataServiceContext derived from TableServiceContext. Inside that class I have the following method:
public DataServiceQuery<Doc开发者_StackOverflowument> Documents
{
get
{
return this.CreateQuery<Document>("Documents");
}
}
Is there a way to get rid of the string constant passed to CreateQuery and instead obtain the table name used by CloudTableClient.CreateTablesFromModel(typeof(DocumentDataServiceContext))?
No. At the end of the day, the CreateQuery() must have the table name to query against. You can of course use convention or reflection to derive what that table name will be in another method, but at some point a string must be passed to CreateQuery.
public DataServiceQuery<T> CreateQueryByConvention<T>()
{
return this.CreateQuery<T>(typeof(T).ToString());
}
精彩评论