My repository is being exposed through UnitOfWork
and Add
method have only following code:
public void Add(Employee emp)
{
context.add(emp);
}
Then, from UnitOfWork, i am calling the Add() method with this code:
this.UnitOfWork.EmployeeRepository.Create(emp);
this.UnitOfWork.Commit(); // This calls SaveChanges() EF method
Now the issue is how can i obtain the Id
of newly created object here?
After
SaveChanges
the employee entity wil have the new id assigned. Find a way to return it to higher level methods.