I want return two types to the calling method, i know that we cannot use out or ref in WCF RIA.
i have created a custom class to get necessary info like this :
[DataContract]
public class Web_GetPrivilegesResult {
[Include]
[DataMember]
public List<tblPrivilege> ResultList { get; set; }
[DataMember]
public Guid? ParentGroupID { get; set; }
}
[Invoke]
public Web_GetPrivilegesResult Web_GetPrivileges(Guid id, bool isSuperAdmin, bool isEnable, bool returnAccessListIfDisbaled) {
...
}
On the client side (silverlight application) when the function is called, it returns only ParentGroupID
- ResultList
isn't retruned. how can i correct this ?
UPDATE
Last changed Codes :
[DataContract]
public class Web_GetPrivilegesResult {
//[System.ComponentModel.DataAnnotations.Composition]
//[Include]
[DataMember]
public List<tblPrivilege> Result { get; set; }
[DataMember]
public Guid? ParentGroupID { get; set; }
}
//[Query]
[Invoke]
public Web_GetPrivilegesResult Web_GetPrivileges(Guid id, bool isSuperAdmin, bool isEnable, bool returnAccessListIfDisbaled) {
tblUsersAndGroup usersAndGroup = new tblUsersAndGroup() { ID = id, IsSuperAdmin = isSuperAdmin, IsEnable = isEnable };
Guid? parentGroupID;
List<tblPrivilege> result = GetPrivileges(usersAndGroup, out parentGroupID, returnAccessListIfDisbaled, this.DataContext);
//System.Data.Linq.DataLoadOptions options = new System.Data.Linq.DataLoadOptions();
//options.LoadWith<Web_GetPrivilegesResult>(q => q.Result);
//this.DataContext.LoadOptions = options;
//List<Web_GetPrivilegesResult> res = new List<Web_GetPrivilegesResult>();
//res.Add(new Web_GetPrivilegesResult() { ParentGroupID = parentGroupID, Result = result });
return new Web_GetPrivilegesResult() { ParentGroupID = parentGroupID, Result = result };
}
thanks
Because of using
[Include]
attribute, In the query method, you must ensure that the associated entities are actually loaded by using the Include method on the query.You will need to explicitly request (using LINQ to Entities) that the data for the
ResultList
propertiy on each Web_GetPrivilegesResult entity are retrieved from the database, using theInclude
method in the query, like so:UPDATE:
Just add
.Include("ResultList")
at the end of thereturn
in yourWeb_GetPrivileges(Guid id, bool isSuperAdmin, bool isEnable, bool returnAccessListIfDisbaled)
method !UPDATE2:
You can see this and this for Linq2SQL equivalent of
Include()