Linq2Sql relationships and WCF serialization problem

Posted by devmania on Stack Overflow See other posts from Stack Overflow or by devmania
Published on 2010-03-15T09:16:26Z Indexed on 2010/03/15 9:19 UTC
Read the original article Hit count: 513

Filed under:
|
|

hi, here is my scenario i got

Table1

  • id
  • name

Table2

  • id
  • family
  • fid

with one to many relationship set between Table1. id and Table2.fid

now here is my WCF service Code

 [OperationContract]

public List<Table1> GetCustomers(string numberToFetch)
{
    using (DataClassesDataContext context = new DataClassesDataContext())
    {
        return context.Table1s.Take(int.Parse(numberToFetch)).ToList( );
    }
}

and my ASPX page Code

<body xmlns:sys="javascript:Sys"   
    xmlns:dataview="javascript:Sys.UI.DataView">  
  <div id="CustomerView"   
      class="sys-template"  
      sys:attach="dataview"  
      dataview:autofetch="true"  
      dataview:dataprovider="Service2.svc"  
      dataview:fetchParameters="{{ {numberToFetch: 2} }}"  
      dataview:fetchoperation="GetCustomers">  
      <ul>  
          <li>{{family}}</li>  
      </ul>  
  </div> 

though i set serialization mode to Unidirectional in Linq2Sql designer i am not able to get the family value and all what i get is this in firebug

{"d":[{"__type":"Table1:#","id":1,"name":"asd"},{"__type":"Table1:#","id":2,"name":"wewe"}]}

any help would be totally appreciated

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about wcf