1
저는 LINQ Entity Framework를 사용하고 있으며 절차를 사용하여 여러 작업을 수행하기 전에 새로 삽입 된 ID 레코드에 액세스해야하는 시나리오를 보았습니다. 다음은 코드 sinppet이다 : 다음 함수에SaveChanges 메서드가 호출되기 전에 새로 삽입 된 ID에 액세스하는 중
public void SaveQuote(Domain.Quote currentQuote)
{
try
{
int newQuoteId;
//Add quote and quoteline details to db
if (currentQuote != null)
{
using (QuoteContainer quoteContainer = new QuoteContainer())
{
**quoteContainer.AddToQuote(currentQuote);**
newQuoteId = currentQuote.QuoteId;
}
}
else return;
// Execution of some stored Procedure by using above newly generated QuoteId
}
catch (Exception ex)
{
throw ex;
}
}
quoteContainer.SaveChanges();가 호출되어 DB 변경 사항을 커밋합니다.
위의 접근 방법이 올바른지 제안 할 수 있습니까?