使用EF 6在两个表中插入数据时的性能开销

时间:2017-11-08 11:43:30

标签: c# performance entity-framework ado.net entity-framework-6

我正在使用EF6执行CRUD操作。我需要在两个表中插入数据,它按预期工作,但在函数本身下面需要3秒钟。我不知道为什么,但我需要弄清楚并缩短这段时间。

 public int SaveRequestDetails(RequestEntity requestEntity)
    {

        try
        {
            if (requestEntity != null)
            {
                Request request = new Request();
                request.SourceMessageXML = requestEntity.SourceMessageXml;
                request.RequestMessageXml = requestEntity.RequestMessageXml;
                request.CreatedDate = DateTime.UtcNow;


                RequestDetails requestDetail = new RequestDetails();
                requestDetail.ClientFlag = false;
                requestDetail.CreatedDate = DateTime.UtcNow;
                requestDetail.RequestDateTime = DateTime.UtcNow;
                requestDetail.EmailFlag = false;


                request.RequestDetails.Add(requestDetail);

                _unitOfWork.RequestRepository.Insert(request);
                _unitOfWork.Save();  
            }
        }
        catch (Exception ex)
        {

        }

    }

非常感谢任何帮助。提前致谢。

0 个答案:

没有答案