Base solution for your next web application
Open Closed

Entity with string ID #9154


User avatar
0
pascald created

HI,

I created an entity with a string ID.

public class Location : FullAuditedEntity<string> , IMustHaveTenant
    {
			public int TenantId { get; set; }
			

		[Required]
		[StringLength(LocationConsts.MaxDescriptionLength, MinimumLength = LocationConsts.MinDescriptionLength)]
		public virtual string Description { get; set; }
		

    }

As the ID must be provided by the user and the CreateOrEdit is using the ID to decide to do an edit or an insert (and it is never empty in this case) what would be the best way to handle this situation.

Also how to validate for duplicate IDs ? Should I add a function in my LocationsAppService to make the validation on the client side?

Thanks,

Pascal


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    I think it is feasible to add an application service method to check if the id is duplicated.