LINQ - Data Serilization problem during communicating through WCF service

Asked By vijay kumar
09-Jul-09 08:16 AM

Hello All,

I have a WCF service and there is a method which fetches some data from database through LINQ Query and returns IQuerable.

When i am trying to access this method from my web application. It is not feteching data instead it issaying data is  notserialized.....

Can any one help me what to do in this case....???

Thanks And Regards

Vijay Kumar

  Michael Detras replied to vijay kumar
25-Aug-09 03:15 AM

Hi Vijay,

Have you solved the problem already? If I understand your question correctly, you are directly returning the results from the LINQ query. However, WCF should be able to serialize these objects. Instead of returning the results directly, you should return objects of another type adorned with the DataContract attribute. This tells WCF to use the DataContractSerializer to serialize any instance of that type.

As an example, if you have an Employee class, then you should create another class like the one below:

[DataContract]

public class EmployeeData

{

   [DataMember]

   public int Id { get; set; }

}

After getting the results from the LINQ query, create an EmployeeData for each result, which you will then use as the return value of the WCF service operation.

Create New Account
help
LINQ in asp.net I want to know the very basics of linq in asp.net? How to use this in asp.net? Regards kiruba.e Language-Integrated Query (LINQ) is a set of features introduced in Visual Studio 2008 that extends powerful query capabilities to the language syntax of C# and Visual Basic. MSDN has a popular set of samples that demonstrate various aspects of LINQ, samples for both Visual C# and Visual Basic. These cover a range of areas, including basic examples- http: / / msdn.microsoft.com / en-us / vstudio / aa336746 What is the purpose of LINQ Providers in LINQ? LINQ Providers are a set of classes that takes a LINQ query and dynamically generates
Linq Query of class PropertyInfo .NET Framework I'm trying to do a linq query of a class's PropertyInfo[] to retrieve all properties that are of type nullable datetime. Unfortunately, it's prop.GetValue(cust, null) where value = = DateTime.MaxValue | | value = = DateTime.MinValue select value; Jon keywords: Linq, Query, of, class, PropertyInfo description: I'm trying to do a linq query of a class
Are Linq-SQL methods commutative .NET Framework Are Linq-SQL methods commutative ? Should the following queries return same or different results ? var query = query.Skip(n).Take(m); var query = query.Take(m).Skip(n); Andrus. C# Discussions SQL Server (1) MySQL (1) LLBLGen (1) LINQ (1) PostgreSQL (1) Elements (1) ThenBy (1) Otherwise (1) Andrus, Absolutely different results. Assuming the the same on each of them (because Skip and Take make no sense without ordering, LINQ to SQL will create an order for you, which irritates me to no end, but
sub-query in linq LINQ how to use the SubQuery in LINQ??? To use the sub-Query in LINQ you have to do your LINQ query like below example one var query = from a in db.ONExport let ExportType = (from b
Linq query Hi I'm working for asp.net application, where i have to implement MVC architecture. For this i have to use LINQ. But i'm new to work on this. And im totally got confused with this Plzz explain me about which topics do i need to learn in LINQ and also explain simple quries . Cheers, Samantha. What are the four LINQ Providers that .NET Framework ships? 1. LINQ to Objects - Executes a LINQ query against a collection of objects 2. LINQ to XML - Executes an XPATH query against XML