Mobile Services query exception
Asked Answered
F

1

5

When I use code with generic:

    var parenttable = MobileService.GetTable<TParent>();
    var testid = await parenttable.Where(prnt => prnt.Id == 20).ToListAsync();

where TParent: IEnity

public interface IEnity
{
    int Id { get; set; }
}

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();

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

Frymire answered 21/6, 2013 at 11:46 Comment(0)
T
9

Know that it's an old question but the answer is that you have to tell that this generic type is also a class.

where T : class, IEnity
Tillotson answered 11/2, 2014 at 22:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.