WCF DataContract class generated dynamically

c# dynamic-linq expression-trees linq wcf

Question

Is there any way to return an array of objects of type DynamicClass from WCF method?

I'm using Dynamic Linq Library in my WCF service, so as to select columns of database table , as per the request from clients. The client code should look like this:

//client side code
string whereClause = "FeatureId >= 6 and FeatureId <= 180";
string selectClause = "New(FeatureName as Name, FeatureId as Id)";
client.RequestAsync("Feature", "FeatureDB", whereClause, selectClause);

Feature is the name of the table from which I want to select two columns only, viz. FeatureName and FeatureId, satisfying the condition in the where clause.

Here, the problem is that the query runs fine on the server, but WCF is unable to send it back to the client. My guess is that the dynamically created class which defines only the selected columns is not declared DataContract, so WCF isn't able to work with it.

So any solution to this problem?

Or any alternative? The goal is, I don't want to return all columns of the database table, because I don't need all of them on the client side. So I don't see any point sending all columns back to the client, who will discard it anyway.

1
0
6/8/2011 1:17:14 PM

Popular Answer

Have you considered implementing a WCF Data Service?

0
6/8/2011 2:35:34 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow