dstr
dstr

Reputation: 8928

Sending Linq to SQL classes over webservice

I have a windows application and a web service. Both have a Linq to SQL mapper with Customer table on them. Same table from the same database, same everything. I tried to send winapp.Customer object to web service but the webserviceReference.MyMethod() accepts webservice.Customer object and doesn't accept winapp.Customer as parameter. Tried to cast winapp.Customer to webservice.Customer but didn't work either. Is there a way to accomplish this?

Upvotes: 2

Views: 618

Answers (2)

John Saunders
John Saunders

Reputation: 161773

No, there is no way to accomplish this using ASMX web services. They require that the proxy type and the real type be different types.

You can accomplish this using WCF, though it breaks the idea of SOA (the client and server will be tied together by the common class code).

Finally, there are problems with passing LINQ to SQL or Entity Framework classes using web services of any kind. Microsoft messed up and serializes implementation-dependent data when passing between tiers. This may make sense when the tiers are on the same computer, but makes much less sense when they are on different machines.

Upvotes: 3

Justin Niessner
Justin Niessner

Reputation: 245429

In your WinApp, you'll probably have to write an explicit conversion from winapp.Customer to webservice.Customer.

Upvotes: 0

Related Questions