2017-12-28 11 views
0

Entity fromawork 5.0에서 MySQL로 저장 프로 시저 호출을 만들려고합니다. MySQL에 연결할 수 있지만 저장 프로 시저를 호출 할 때 빈 데이터 (데이터 없음)가 발생합니다. 내가 저장 porcedure에서 .edmx 파일을 업데이트하고 때마다 내가Enitiy Framwork 5에서 MySQL로 저장 프로 시저 호출

public virtual ObjectResult<usp_GetFileType_Result> usp_GetFileType() 
     { 
      return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<usp_GetFileType_Result>("usp_GetFileType"); 
     } 

좀 더 일에 관찰입니다 점점 ​​오전 - 내가 저장 프로 시저 호출을 위해 사용하고 코드 아래

-이 문제를 해결할 수있는 방법 이 같은 빈 모델 -

namespace MySQLwithEntity 
    { 
     using System; 

     public partial class usp_GetFileType_Result 
     { 

     } 
    } 

그래서 내가 수동으로 아래처럼 작성 -

namespace MySQLwithEntity 
    { 
     using System; 

     public partial class usp_GetFileType_Result 
     { 
      public int FileTypeId { get; set; } 
      public string FileTypeName { get; set; } 
     } 
    } 

개하지만 아직도 내가 무엇입니까 빈 값 - 작동하지 않는 MySQL의에서 SP를 호출 위의 방법

이유 -

enter image description here

답변

0

시간 검색 후 나는 누군가에게 도움이 this.It 힘의 해결책을 발견 자동 생성 된 엔티티 모델이 비어있는 경우 .edmx 파일이 MySQL SP에서 반환 한 열에 대한 매핑을 생성하지 못했습니다.

namespace MySQLwithEntity 
    { 
     using System; 

     public partial class usp_GetFileType_Result 
     { 

     } 
    } 

넣어 entititis 수동 - 아래 같은 .edmx 파일을 수동으로

namespace MySQLwithEntity 
    { 
     using System; 

     public partial class usp_GetFileType_Result 
     { 
      public int FileTypeId { get; set; } 
      public string FileTypeName { get; set; } 
     } 
    } 

만든 mappinng, 그것은 좋습니다,하지만 난 선택의 여지가 없었다되지 않는다.

<FunctionImportMapping FunctionImportName="usp_GetFileType" FunctionName="Model1.Store.usp_GetFileType"> 
       <ResultMapping> 
       <ComplexTypeMapping TypeName="Model1.usp_GetFileType_Result"> 
       <ScalarProperty Name="FileTypeId" ColumnName="FileTypeId" /> 
       <ScalarProperty Name="FileTypeName" ColumnName="FileTypeName" /> 
       </ComplexTypeMapping> 
      </ResultMapping> 
      </FunctionImportMapping> 

둘째는, 코드가 SP에 전화 - .edmx 파일은 XML 파일로 열 때 "CSDL 내용"부분과 "C-S 매핑 내용"섹션을 편집해야합니다. 나는 다음과 같은 SP를 호출하는 코드를 변경 - MySQL은

public virtual IList<usp_GetFileType_Result> GetCustOrderHist() 
     { 
      IList<usp_GetFileType_Result> data = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreQuery<usp_GetFileType_Result>("CALL usp_GetFileType();").ToList(); 

      return data; 
     } 

Call은 MS SQL의 EXEC의 equivelent입니다.