user759141
user759141

Reputation: 587

WCF ria services return list of complex types

I have a complex type entity

public class ComplexEntity : ComplexObject
{
private int _ID;
private string _Name;
private int _ParentID;

[Key]
[DataMember]
public int ID { get;set;}

[DataMember]
public string Name {get;set;}

[DataMember]
public int ParentID {get;set;}

}

and another one

[DataContract]
public class ComplexEntitiesList : ComplexObject
{
[DataMember]
[Include]
[Association("CEntities_CEntity","ID","ParentID")]
public List<CompelxEntity> List {get;set;}

[Key]
[DataMember]
public int ID {get;set;}

public int LKEntitiesList()
{
List = new List<LKEntity>;
}

and a method:

[Invoke]
public ComplexEntitiesList GetPS()
{
return new ComplexEntitiesList() { List = /*..some logic*/});
}

On the server side everything's perfect however the list comes empty at the client side Any clues? }

Upvotes: 3

Views: 3218

Answers (1)

Jehof
Jehof

Reputation: 35544

I think the Include will not work wit Invoke-Operations. Take a look at this question on silverlight.net and see Colin Blairs answer. Your method GetPs() should return a normal collection (aka. List) containing your complex objects.

[Invoke]
public IEnumerable<ComplexEntity> GetPS() {
  return new List<ComplexEntity>() { /*..some logic*/});
}

Upvotes: 3

Related Questions