Base solution for your next web application
Open Closed

How to get the entity Id after insert? #237


User avatar
0
sayram created

In my categoryService im adding category entity with this codes.

    public void CreateCategory(Category entity)
    {
       _categoryRepository.Insert(entity);
    }

I need the Id number of the inserted entity. How to get it? Ty.

I dont want to use GetCategoryByTitle or something like that because there can be same named categories.


2 Answer(s)
  • User Avatar
    0
    sayram created

    ok sorry found InsertAndGetId method :)

    bunu akıl ettiğn için teşekkürler dostum. Mükemmellik ayrıntılarda gizlidir. :)

  • User Avatar
    0
    hikalkan created
    Support Team

    See repository document: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Repositories#DocInsertEntity">http://www.aspnetboilerplate.com/Pages/ ... sertEntity</a>

    There is a method named InsertAndGetId for that.