views:

197

answers:

2

Hi Chaps,

I created a new solution with 3 projects: My "Client" is a ASP.Net Web Application. This should display the information. My Businesslayer should have all logic in it, it's designed as a normal class libery. My "Server" is a WebService. This connect via Linq to the database and get the Information.

Now only my Server knows Linq and knows the Database (how it should be). But how can I give Linq Objects throug the WebService to my Business and my WebApp Layer to use it There?

For my understand there must be a way, because I have e.g. a complete user object with all needed Information with Linq, so I don't must create a own one, must I?

+1  A: 

I would recommend you to create internal classes corresponds to the linq entities and expose those objects through the web service instead. Then you create mapping methods within the service application to map between those types.

Fredrik Mörk
But isn't it doubled then?So I have the one object via liny and the other object self made. Isn't it smarter to make the linq classes in a fourth project and reference it to the business, client and server layer, so evereybody knows and I can send (maybe, I don't know, it's only an Idea) th linq objects through the weservcice?
Kovu
Yes but you should maintain a separation from the consumers of your web service and what it uses internally. Otherwise you'll be introducing unnecessary dependence in your clients. Don't worry about copying the info until you specifically know its an issue.
Preet Sangha
Sorry I must ask again, because I'm very new in Linq. I Read a lot of things about Linq in ASP.Net and e.g. how to very very easily bind a Linq object tot a gridview or somethink like this. When I use my own objects, isn't it harder?
Kovu
@Kovu: the idea is to separate the classes that are "hard-wired" to you database layout for LINQ from the classes exposed to the service consumers. If you send back those as IEnumerable<YourEntityClass> or IList<YourEntityClass>, the consumer can still use LINQ to query the lists and use the result for databinding, but there will not be a hard coupling all the way from the client to the database.
Fredrik Mörk
Thats sounds great.You mean I must have an Object with the same Rows and datatypes of this rows on the client side?How I can go througt the WebService on the one side the Linq- and on the other side my Object?Do you have Code Examples for me?
Kovu
+1  A: 

Linq should be covered as well as database. Your business-logic layer and server should better have common core objects used in client-server calls: this also will provide you easy means to add some additional info that is not stored in DB (if needed in future).

terR0Q