All work

Select view

Select search mode

 
50 of 92

ExpandedWrapper over collection property throws TargetInvocationException

Duplicate

Description

I'm using WCF Data Services (odata) over a NHibernate backend and I have encountered problems when expanding collection properties.

I have the following (simplified) model:

public class City
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IList<Area> Areas { get; set; }
}

public class Area
{
public virtual int id { get; set; }
public virtual string Name { get; set; }
public virtual City City { get; set; }
}

If I run the following query:

var city = (from c in session.Query<City>()
where c.ID == 1
select new ExpandedWrapper<City, IList<Area>> { Description = "Areas", ProjectedProperty0 = c.Areas, ReferenceDescription = "", ExpandedElement = c }).ToList();

I get an TargetInvocationException at ResultTransformer.TransformTuple(), line 25. TransformTuple gets called with the tuple-parameter containing a city and an area (If the City contains 5 areas, TransformTuple would get called 5 times, with the tuple containing the same city and different areas for each call).

As I understand it, the ExpandedElement will be set to city ("c") from the tuple and ProjectedProperty0 to area ("c.Areas") from the tuple, but since ProjectedProperty0 expects an IList<Area> and not an Area it throws.

I'm not sure but even if the invoke would succeed, TransformTuple would get called n times, where n is the number of associated areas...and that does not seem right either.

Environment

None

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created December 10, 2012 at 10:19 AM
Updated September 9, 2014 at 12:54 PM
Resolved December 10, 2012 at 12:26 PM

Activity

Show:
Who's Looking?