Base solution for your next web application

Activities of "mohammed al-qaisi"

Answer

Hello All;

My Project structure like this

  • MyProject.Core
  • MyProject.App
  • MyProject.EF [list:20feq927][:20feq927]EmpRepository (Stored procedure here as above implementation)[/:m:20feq927] [:20feq927]MyProject.Test[/:m:20feq927][/list:u:20feq927]

In my test app

private readonly IEmpRepository _EmpRepository;
		//Constructor
		public UnitTestClass()
        {
           _EmpRepository = LocalIocManager.Resolve<IEmpRepository>();
        }
		[TestMethod]
        public void Should_Add_Employee_With_Authorized_User()
        {
           var result = _EmpRepository.GetAllWithDepartment(1);
           result.Count().ShouldBe(100);
        }
  • I got exception:"The operation cannot be completed because the DbContext has been disposed".
  • Is that the appropriate way to use this (like ref --MyProject.EF -- into --MyProject.Test--).

Thank you :)

Answer

Thank you

I use this:

public IEnumerable<Employee> GetAllWithDepartment(int? deptID)
        {

            var departmentIDParameter = deptID != null ?
            new SqlParameter("@dept_id", deptID) :
            new SqlParameter("@dept_id", typeof (int));

            return Context.Database.SqlQuery<Employee>("spGetEmployeesWithUsersWithDepartments @dept_id", departmentIDParameter);
        }
Answer

Wonderful .... Thanks again :D

Answer

Im very thankful :D hopefully this will work

Showing 1 to 4 of 4 entries