Mobile Services query exception

R.T*_*tov 5 c# azure query-expressions azure-mobile-services

When I use code with generic:

    var parenttable = MobileService.GetTable<TParent>();
    var testid = await parenttable.Where(prnt => prnt.Id == 20).ToListAsync();
Run Code Online (Sandbox Code Playgroud)

where TParent: IEnity

public interface IEnity
{
    int Id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

I catch the exception:

The member 'Id' is not supported in the 'Where' Mobile Services query expression 'Convert(prnt).Id'.

But if I change the generic to type:

   var parenttable = MobileService.GetTable<Category>();
   var testid = await parenttable.Where(prnt => prnt.Id == 20).ToListAsync();
Run Code Online (Sandbox Code Playgroud)

I have normal result. Why? And how can I use generic?

us3*_*s3r 9

知道这是一个老问题,但答案是你必须告诉这个泛型类型也是一个类.

where T : class, IEnity
Run Code Online (Sandbox Code Playgroud)