Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Populate a property on an Entity using an interface #3548


User avatar
0
bilalhaidar created

Hello,

Similar to the interfaces present currently in Abp the CreationFullEdit and others, I need to populate a common property on all my entities which is the full entity name. How can I implement such thing in Abp?

Thanks


6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you explain your case a little bit more ? For example, do you just want to add a field named FullEntityName or do you also want to save a generated value to this property while creating an entity ?

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    In fact I need to auto generate a field to be the Entity Full Name. So I thought of doing it similar to those interfaces you have in the framework that adds CreatedOn, CrratedBy etc. How shall I proceed?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Then you can check our implementation in AbpDbContext <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/2f79821b3c09132394ec01f1673b7fad8e6893af/src/Abp.EntityFramework/EntityFramework/AbpDbContext.cs">https://github.com/aspnetboilerplate/as ... Context.cs</a>.

    You can override ApplyAbpConceptcs method to insert your logic here.

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    Thanks Ismail. Where would I add this code? I shall change in the boilerplate code and build it? Or override this method in the application specific Db Context?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi Bilal,

    Yes, you should override it in your DbContext. Don't forget to call base method :).

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    Thanks :)