我有存储库:
namespace Zinc.Repositories.EF.Scorm
{
public class ScormModuleRepository : Repository<ScormModule>, IScormModuleRepository
{
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="ScormModuleRepository"/> class.
/// </summary>
/// <param name="objectContext">The object context.</param>
public ScormModuleRepository(ObjectContext objectContext)
: base(objectContext)
{
}
#endregion
/// <summary>
/// Clear all records (for user and selected scorm module) from the scorm.userscormmoduledata and scorm.userscormmoduleassessment tables.
/// </summary>
/// <param name="id"></param>
/// <param name="userScormModuleId"></param>
public void ResetModule(int id, int userScormModuleId, int currentUser)
{
using (SqlConnection conn = new SqlConnection(ZincModelContainer.CONNECTIONSTRING))
{
using (SqlCommand cmd = conn.CreateCommand())
{
conn.Open();
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "[Zinc].[ResetUserScormModuleData]";
SqlParameter param = new SqlParameter("@userId", System.Data.SqlDbType.Int);
param.Value = id;
cmd.Parameters.Add(param);
SqlParameter param2 = new SqlParameter("@userScormModuleId", System.Data.SqlDbType.Int);
param2.Value = userScormModuleId;
cmd.Parameters.Add(param2);
SqlParameter param3 = new SqlParameter("@currentUser", System.Data.SqlDbType.Int);
param3.Value = currentUser;
cmd.Parameters.Add(param3);
cmd.ExecuteNonQuery();
}
}
}
在我的控制器中,我有:
[HttpGet]
public ActionResult UserDetails(int id)
{
var user = ZincService.GetUserForId(id);
if (user == null || user.Customer.CustomerId != CurrentCustomer.CustomerId)
return DataNotFound();
ManageUserViewModel viewModel = new ManageUserViewModel();
viewModel.User = user;
viewModel.IsLockedOut = MembershipService.IsUserLocked(user.Email);
viewModel.IsActivated = user.DateTimeActivated.HasValue && MembershipService.IsUserApproved(user.Email);
viewModel.IsArchived = user.IsArchived;
var scormModuleRepository = new ScormModuleRepository();
var trainingService = new Zinc.ServiceImplementations.TrainingService(scormModuleRepository);
IEnumerable<UserTrainingDataModel> ids = trainingService.GetTrainingModulesForUser(user.UserId);
viewModel.TrainingModules = ids;
return View(viewModel);
}
我收到一条错误消息:var scormModuleRepository = new ScormModuleRepository();
说明:
错误 2 'Zinc.Repositories.EF.Scorm.ScormModuleRepository' 不包含采用 0 个参数的构造函数 C:\TFSPreview\Zinc\Web\Project\Areas\User\Controllers\ManageController.cs 102 35 Zinc.Web
我必须在这里传递什么是 ObjectContext 类型的?