Base solution for your next web application
Open Closed

Unique Name set in Object and Respective #769


User avatar
0
Hasan created

Hello Sir

This could be the simplest question but would like to ask you how to do that

I have a object called Brand

[Table("Brands")]
    public class Brand : FullAuditedEntity,IMustHaveTenant
    {
        public virtual string Name { get; set; }

        public virtual bool IsActive { get; set; }
        public virtual int TenantId { get; set; }
    }

I want to set the Name as Unique. How to achieve that in ABP ZERO

I am able to see that in RoleService that it throws the error at the place in Method CreateRoleAsync CheckErrors(await _roleManager.CreateAsync(role));

Can you please let me know how to achieve that ?


2 Answer(s)
  • User Avatar
    0
    Hasan created

    I have read about Domain Services

    <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Domain-Services">http://www.aspnetboilerplate.com/Pages/ ... n-Services</a>

    I guess we should have business validation at this place.

    Could you please tell me where to keep the file (Which Project) ?

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    You can put your file in Core project since it is a domain service. You can also add an unique index on Name field of your entity.