Paul, You are doing an anonymous projection query. Anonymous queries are nice, problem is the returned objects are anonymous, so you can't refer to them by type. To program against the returned data, you must define your own custom type and project into it or cast it to object and use reflection to access its properties.
So, the first option is to cast it to object. If you are just gonna bind it to the view than that is sufficient, because XAML binding uses reflection and it will see the properties on your anonymous objects.
IEntityQuery query = Manager .Employees .Where(e => e.EmployeeId == Guid.Parse("2661C686-66CD-4E7A-8E5C-1C0EA43F1D6B")) .Select(e => new { Person = e.Person, Address = e.Person.Address, RegionLocalized = e.Person.Address.Region.RegionLocalizeds.Where(rl => rl.RegionId == e.Person.Address.RegionId) });
EntityQueryOperation queryOperation; yield return queryOperation = query.ExecuteAsync();
yield return Coroutine.Return(queryOperation.Results.Cast<object>().First());
The second option is to project into a custom type.
IEntityQuery<MyCustomType> query = Manager .Employees .Where(e => e.EmployeeId == Guid.Parse("2661C686-66CD-4E7A-8E5C-1C0EA43F1D6B")) .Select(e => new MyCustomType { Person = e.Person, Address = e.Person.Address, RegionLocalized = e.Person.Address.Region.RegionLocalizeds.Where(rl => rl.RegionId == e.Person.Address.RegionId) });
EntityQueryOperation<
MyCustomType> queryOperation; yield return queryOperation = query.ExecuteAsync();
yield return Coroutine.Return(queryOperation.Results.First());
The type should look like this:
[DataContract] public class
MyCustomType : IKnownType { [DataMember] public ??? Person { get;set; }
[DataMember] public ??? Address { get;set; }
[DataMember] public ??? RegionLocalized { get;set; } } You can read more on projection queries here: http://drc.ideablade.com/xwiki/bin/view/Documentation/query-anonymous-projections - http://drc.ideablade.com/xwiki/bin/view/Documentation/query-anonymous-projections
|