Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The property 'Private' is not a String or Byte array. Length can only be configured for String and Byte array properties

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!

like image 547
Anh Ta Avatar asked Dec 25 '22 21:12

Anh Ta


1 Answers

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; }
like image 103
Anh Ta Avatar answered May 03 '23 12:05

Anh Ta