我有以下TableServiceContext类的书,我想通过partitionKey查询表Books,请忽略我使用分区键作为书名的事实,这只是为了我的学习方便
public class BookDataServiceContext: TableServiceContext
{
public BookDataServiceContext(string baseAddress, StorageCredentials credentials)
: base(baseAddress, credentials)
{
}
public IQueryable<Book> Books
{
get
{
return this.CreateQuery<Book>("Books");
}
}
public void AddMessage(string name, int value)
{
this.AddObject("Books", new Book {PartitionKey=name, BookName = name, BookValue = value});
this.SaveChanges();
}
public Book GetBookByPartitionKey(Guid partitionKey)
{
var qResult = this.CreateQuery<Book>("Books");
This doesnt work ----> // qResult = qResult.Where(e => (e.PartitionKey.CompareTo(partitionKey)==0));
}
}
我在最后一行得到“无法将类型'System.Linq.IQueryable'隐式转换为'System.Data.Services.Client.DataServiceQuery'。存在显式转换(您是否缺少演员表?)”。
任何帮助将不胜感激!