У меня есть этот счет Модель:FindBy метод Entity Framework
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);
}
, что проблема с этим? Буду признателен за любую оказанную помощь.
возможный дубликат метода [FindBy Id в EntityFramework] (http://stackoverflow.com/questions/14865013/findby-id-method-in-entityframework) – Jehof
изменить свое существование перед тем, как начать новый – Jehof