locked
EF + WCF + SSRS RRS feed

  • Question

  • Hi

    Using .NET 4.0, I am currently investigating using WCF to expose XML data to SQL Server Reporting Services (2005). I have a prototype working, but for data acess I used ADO.NET Core (i.e. DataSet etc).

    Has anyone done something similar but used EF?

    How can I serialise EF objects into XML from my WCF service? In my current implementation I have a simple implementation that returns, from my WCF service, XML data to SSRS i.e. SSRS calls my FetchAccounts method below: 

     

     

    Please note that the SSRS and WCF bit of the architecture are a must. I am just trying to find out how easy (or difficult) it would be to replace the data access layer (Core ADO) with EF.

    Thanks


    Regards Amir

      public XmlElement FetchAccounts(int introducerID)
    
      {
    
       XmlDocument doc = null;
    
       DataSet ds = new DataSet();
    
    
    
       // Code to fetch data into the DataSet
    
    
    
       // Get the XML data of the DataSet
    
       doc = new XmlDocument();
    
       doc.LoadXml(ds.GetXml());
    
    
    
       return doc.DocumentElement;
    
      }
    
    
    • Edited by amir tohidi Monday, May 10, 2010 2:43 PM Added clarification
    Monday, May 10, 2010 2:12 PM

Answers

  • Please ignore the last post. My grid view is now showing child object too (there was a typo in my code).

    But I am still baffled by this behaviour because according to the MSDN doc, I shouldn't be receiving child objects at the client end.

    Can anyone please explain what's going on?

    Thanks


    Regards Amir
    • Marked as answer by amir tohidi Thursday, May 27, 2010 1:09 PM
    Tuesday, May 11, 2010 3:31 PM

All replies

  • I have managed to get my WCF service and SSRS report to work. The trick was to change the signature of my service method to:

    public List<Account> FetchAccounts(int introducerID)

    This work because the generated objects have SerializableAttribute and DataContractAttribute applied. In my case, Account is an EF object and I am returning a bunch of them out of my WCF service using List<>

    All was well till I tried to drill down into the Transaction objects associated with each account. It transpires that there is a XML serialisation feature (link):

    When you use binary serialization and WCF data contract serialization, if the object being serialized has related objects in the object graph, those objects are also serialized. XML serialization does not serialize related objects.

    Is there a way of overcoming this limitation?


    Regards Amir
    Tuesday, May 11, 2010 3:02 PM
  • I just noticed that if I debug my client, I can actually drill down into the (child) Transaction objects! So, the WCF service seems to be returning child objects.

    But when I try to display the child objects on a WinForm DataGridView, I see nothing (not even an error).

    Any ideas?


    Regards Amir
    Tuesday, May 11, 2010 3:18 PM
  • Please ignore the last post. My grid view is now showing child object too (there was a typo in my code).

    But I am still baffled by this behaviour because according to the MSDN doc, I shouldn't be receiving child objects at the client end.

    Can anyone please explain what's going on?

    Thanks


    Regards Amir
    • Marked as answer by amir tohidi Thursday, May 27, 2010 1:09 PM
    Tuesday, May 11, 2010 3:31 PM