Blog of Mike Moser, containing my thoughts, comments and questions. RSS Feed


Linq and Extension Methods

I am working on making Video.Show a more traditional 3-Tier app.  The architectural approach I am using looks like:

image

*Please note the goal of this project is to keep the application simple and approachable.  This is not a recommendation of an architecture that meets every software project.  This approach meets the goals of this project.

The data layer does not return Linq objects to the other tiers, only model objects are passed between tiers.  So in this type of architecture, you will need mappers, to translate the data objects to your model objects.  Since I want to keep my app simple.  I have decided to take advantage of extension methods, to keep the project and and syntax clean.

So my data object may have a method that looks like this:

image

Notice the "ToModel()" method.  The Linq object that's returned from the query does not by default have this method.  I have mappers for each type I want to convert to my model objects.  That class looks like:

  image

*Note:  The Mapper class needs to be in the same namespace as the Linq object.

 
Posted by Mike Moser | 0 Comments | Trackback Url | Bookmark with:        
Tags:

Links to this Post

Comments

Name:
URL:
Email:
Comments:

CAPTCHA Image Validation