3 levels nhibernate + wcf + Silverlight

Recently I was asked to develop a project. The architecture looks like this:

  • Level 1: DataAccess Database on Nhibernate
  • 2 levels: a business level based on the WCF service and some basic classes
  • Level 3: Silverlight Based Viewing

I am going to use DTO objects to transfer data between the 2nd and 3rd levels.

I realized that the project will have a huge domain model, and many business units must support standard and custom CRUD operations. At the first level, it will be resolved by the NHibernate + Specification common repository.

But Level 2 (one WCF service) will look like a set of methods that provides a custom and standard DTO CRUD interface for Level 3.

For example, the model looks like this:

class Product {}
class Category {}

DTOS:

class ProductDTO {}
class CategoryDTO {}

"problem" WCF service:

public class DataService
{
  public List<CategoryDTO> GetAllCategories()
  {
  }

  public List<ProductDTO> GetAllProducts()
  {
  }
}

:

public class ProductDataService
{
  public List<ProductDTO> GetAllProducts()
  {
  }
}

 public class CategoryDataService
{
  public List<CategoryDTO> GetAllCategories()
  {
  }
}

:

  • , ?
  • - "" , WCF ?
+5
2

, CRUD "" (, ​​..), 1 GetAllXXX , . , DTO , GetXXX.

:

  • wcf, "" ( 100-200 (1)
  • wcf ""

:

public class DataService<TIn>
{
    protected List<TOut> GetAll<TOut>()
    {
         // handle generic loading and transformation here
    }
}

public class CategoryService : DataService<Category>
{
    public List<CategoryDTO> GetAllCategories()
    {
        return GetAll<CategoryDTO>();
    }
}

public class DataService
{
    protected List<TOut> GetAll<TIn, TOut>()
    {
         // handle generic loading and transformation here
    }

    public List<CategoryDTO> GetAllCategories()
    {
        return GetAll<Category, CategoryDTO>();
    }
}

CategoryD, Automapper, .

, /- DTO, , "".

(1) , . , , :)

+3

All Articles