Dynamic SQL requests

Initialization:

public void Init(IUnityContainer container)
{
    container.RegisterSimpleSql<Development>();
}

Call a service method

using Fuse8.DomainFramework.BusinessService;

public IEnumerable<Development> GetAllEntities()
{
    return new BusinessServiceFacade<Development, int>().FindAll();
}

public Development GetEntityById(int id)
{
    return new BusinessServiceFacade<Development, int>().FindOne(id);
}

public IEnumerable<Development> GetEntityByDevelopmentTypeId(int developmentTypeId)
{
    return new BusinessServiceFacade<Development, int>().Find(x => x.DevelopmentTypeId == developmentTypeId);
}

Request to take a development with depeinding item from the database

public IEnumerable<Development> GetDevelopmentsByType(int id)
{
    return new BusinessServiceFacade<Development, int>().Find(x => x.DevelopmentTypeId == id, item => new { item, item.DevelopmentType });
}


List of supported expressions in the FindOne and Find:
  1. ==, >, <, >=, <=
  2. Contains()

Not supported expressions:
  1. HasValue()

DF will automatically build a SQL request.

Last edited Apr 1, 2013 at 8:17 AM by olgabutova, version 4

Comments

No comments yet.