2012-12-06 3 views
1

내 모델에 Entity Framework (edmx 파일)를 사용하고 WCF를 사용하여 모델에 액세스하고 있습니다. 시도 엔티티 데이터 모델 (예를 들어, 테이블 개체)의 목록을 반환하는 경우 , 나는 오류가 발생 :웹 서비스에서 엔티티 목록 반환

The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

가 여기 내 WCF 코드입니다. IService.cs :

[ServiceContract(CallbackContract = typeof(IPesananCallBack), SessionMode = SessionMode.Required)] 
public interface IPelayanWebService 
{ 
    [OperationContract] 
    List<table> GetAllTables(); 
} 

Service.cs : 모델

public List<table> GetAllTables() 
{ 
    TableModel model = new TableModel(); 
    return model.GetAllTables(); 
} 

내 코드 : 내 클라이언트

public List<table> GetAllTables() 
{ 
    using (restoicdbEntities ent = new restoicdbEntities()) 
    { 
     return ent.table.ToList(); 
    } 
} 

, 나는 단지 그 함수를 호출하고, 오류가 발생했습니다. 자체 데이터 계약을 만들어야합니까? 어쨌든 edmx에서 datacontract를 생성합니까?

업데이트 : 이 엔티티 프레임 워크에서 생성 된 코드이다 : 웹 서비스에서 엔티티 개체를 전달할 좋지 않다처럼

[EdmEntityTypeAttribute(NamespaceName="restoicdbModel", Name="table")] 
[Serializable] 
[DataContractAttribute(IsReference=true)] 
public partial class table: EntityObject 
{ 
    [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] 
    [DataMemberAttribute()] 
    public global::System.Int32 ID_TABLE 
    { 
     get 
     { 
      return _ID_TABLE; 
     } 
     set 
     { 
      if (_ID_TABLE != value) 
      { 
       OnID_TABLEChanging(value); 
       ReportPropertyChanging("ID_TABLE"); 
       ID_TABLE = StructuralObject.SetValidValue(value); 
       ReportPropertyChanged("ID_TABLE"); 
       OnID_TABLEChanged(); 
      } 
     } 
    } 
    private global::System.Int32 ID_TABLE; 
    partial void OnID_TABLEChanging(global::System.Int32 value); 
    partial void OnID_TABLEChanged(); 
} 
+0

어떤 버전의 Entity Framework를 사용하고 있습니까? 엔티티 POCO입니까? –

+0

Im 버전 2.0을 사용하면 내 엔티티가 edmx에서 생성됩니다. – erkape

+0

EF 2.0? 1.0 이후 [4.0, 4.1, 4.2, 4.3, 5.0 및 6.0alpha] (http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework#History) – abatishchev

답변

0

스티브 윌크스, WCF, Entity Framework & Data Contracts에서 제공하는 링크를 읽은 후, 그것은 보인다는 . 그래서 엔티티 객체로부터의 매핑 인 자체 데이터 전송 객체를 생성 한 다음 웹 서비스에서 전달해야합니다.

관련 문제