I tried to follow the Architecture Design at http://techbrij.com/generic-repository-unit-of-work-entity-framework-unit-testing-asp-net-mvc to build a small website but I got this error "The property 'Private' is not a String or Byte array. Length can only be configured for String and Byte array properties." when I call
User user = _userService.GetByName(username); from AccountController.cs
Here the call stack:
> Kad.Repository.dll!Kad.Repository.GenericRepository<Kad.Model.Category>.FindBy(System.Linq.Expressions.Expression<System.Func<Kad.Model.Category,bool>> predicate) Line 32 C#
> Kad.Repository.dll!Kad.Repository.CategoryRepository.GetById(int id) Line 17 C#
> Kad.Service.dll!Kad.Service.CategoryService.GetById(int Id) Line 25 C#
> Kad.dll!Kad.Controllers.AccountController.Login(Kad.Models.LoginViewModel model, string returnUrl) Line 111 C#
The property 'Private' is not a String or Byte array. Length can only be configured for String and Byte array properties.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The property 'Private' is not a String or Byte array. Length can only be configured for String and Byte array properties.
Source Error: Line 32: IEnumerable query = _dbset.Where(predicate).AsEnumerable(); Line 33: return query;
Please tell me what happened with the code? Where I configure wrong!
Thanks, I have found I set MaxLength for property of Class TableCate Entity. I removed it . It works well now!
[Required]
//[MaxLength(1)]
public int Private { get; set; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With