我有这个帐户型号:FindBy方法实体框架
public class Account :IAggregateRoot
{
public Account()
{
}
public Account(Guid accountId)
{
Id = accountId;
}
public Guid Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
}
这仓储类:
public class Repository<T> : IRepository<T> where T : class, IAggregateRoot
{
private readonly DbSet<T> _entitySet;
public T FindBy(T entity)
{
return _entitySet.Find(entity);
}
}
,现在当我想通过标识实体,例如:
public AccountViewModel GetAccountBy(Guid accountId)
{
var account = new Account(accountId);
_unitOfWork.AccountRepository.FindBy(account);
var accountView = account.ConvertToAccountView();
return accountView;
}
我拿到了这个错误:
The specified parameter type is not valid. Only scalar types, such as System.Int32, System.Decimal, System.DateTime, and System.Guid, are supported.
我的行动来呼吁GetAccountBy是这样的:
public ActionResult Edit(Guid accountId)
{
var account = _accountService.GetAccountBy(accountId);
return View(account);
}
是什么问题呢?任何帮助深表感谢。
可能在[EntityFramework中的FindBy Id方法]重复(http://stackoverflow.com/questions/14865013/findby-id-method-in-entityframework) – Jehof 2013-02-14 12:06:49
编辑你的存在在开始新问题之前提出问题 – Jehof 2013-02-14 12:07:30