0

I have my business logic layer and data access layer in separated dll , I used active record design pattern to build my bll ... now I need to host my bll and dal in my mvc project .. I tried to make classes in my models and inherits it's properties and methods from bll (which in another dll) but when I tried to assign base class to inherited one it gives me exception

//Customer class located in mvc model folder which inhireted from EgxCustomer that located in bll in another project
using Egx.EgxBusiness.Inventory;
namespace EgxNMWeb.Models
{
public class Customers:EgxCustomer
{

}
}

//here i try to assign list of EgxCustomer to list of customer
 using Egx.EgxBusiness.Inventory;
 namespace EgxNMWeb.Models
 {
 public class CPanelVM
 {
    Customers currentCustomer { get; set; }
    List<Customers> AllNetwork { get; set; }
    public CPanelVM() 
    {
        AllNetwork = NMModel.GetCustomerNetwork(currentCustomer.CUST_CODE,    Egx.EgxBusiness.Inventory.NM.REF_TYPE.ALL);
    }
   }
   }

what can I do to use my bll which located in another project in my mvc project ?

2
  • What is the exception that you are getting? Commented Apr 19, 2015 at 6:19
  • can't parse from Customer to EgxCustomer Commented Apr 19, 2015 at 6:25

1 Answer 1

0

There is no need for your model classes to be in Models folder. It is just a way to form your code structure (although your view must be in Views folder by default). You can directly use your business logic layer models in your controllers if you want.

I think in your project you can place view models in Models folder.

Sign up to request clarification or add additional context in comments.

3 Comments

and what is the role of dependency injection here and when to use it?
You can use dependency injection pattern to make your code more robust and testable. With DI you separate your controllers from BLL concrete classes. Usually people do this with defining interfaces. IMHO you don't need to define interfaces for POCO entities because they don't have logic in them. But it is a good idea to define an interface for your repository and pass its interface to controller constructor with a dependency container such as Ninject. Take a look at this link for more info: asp.net/mvc/overview/older-versions/hands-on-labs/…
In the article I sent the link mentioned: The advantages of using Dependency Injection pattern and Inversion of Control are the following:Reduces class coupling, Increases code reusing, Improves code maintainability, Improves application testing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.