2012-07-27 3 views
0

이 문제에 대한 많은 설명을 발견했지만 실제로 도움이되지는 못했습니다. 것은 간단합니다. 내 dataModel에 대한 두 테이블이 있습니다 : 이벤트 및 타임 스탬프, 둘 다 필드 EntryID, 그들 사이의 관계가 있습니다 (사실 테이블에있는 테이블은 DB에서 변경을 수행 할 수 없으며 쿼리 만 할 수 있습니다) .On my domainService를 사용하여 각 테이블에서 데이터를 가져 오는 생성 된 메서드가 있습니다. 지금까지는 하나의 테이블에서만 데이터 그리드를 채울 수 있었지만 실제로 필요한 것은 두 테이블에서 모두 표시하는 것입니다. T-SQL에서이 같은 것입니다 :WCF RIA - 두 테이블 결합하기

Select e.EntryID,t.closed_time 
    from Events e inner join TimeStamps t 
    on e.EntryID=t.EntryID 

그래서 내 데이터 그리드에 표시 할 Entry_ID 및 closed_time.I이

내가 새로운 사용자 정의 클래스를 시도 내 문제 해결을위한 도움을 주셔서 감사를

public class CustomTable 
    { 
     public string EntryId { get; set; } 
     public int closed_time { get; set; } 
    } 

    public IQueryable<CustomTable> GetJoined() 
    { 
     return (from i in this.ObjectContext.Events     
       join p in this.ObjectContext.TimeStamps p 
       on i.Entry_ID equals p.Entry_ID 
       select new CustomTable 
       { 
        EntryId = i.Entry_ID, 
        closed_Time = p.Closed_TIME 
       }); 
    } 

이 나 자신에 의해 추가 된 추가 코드입니다, 내가 뭔가를이 방법과 클래스 자체가이 최종 C 내 service.cs

+0

무엇을 시도하고 있습니까? RIA를 통해 이전하는 반품 유형은 무엇입니까? –

+0

위의 추가 정보를 참조하십시오. – Avrum

+1

GetJoined() 메소드로 RIA 호출을하면 어떻게됩니까? 반환 값을 var에 먼저 할당하고 (즉시 반환하는 대신) 결과를 확장 할 수있는 디버거에서 검사하여 실제로 데이터베이스에서 데이터를 다시 가져올 수 있는지 확인합니다. –

답변

0

을에 추가 된, 누락 확신 해요 송시 및 절차 수행, 각 단계 이후에 프로젝트를 빌드하는 것을 잊지 마세요 :

1- Myproject.Web에 새 클래스를 개설 (추가 -> 새 항목 -> 클래스)

namespace Myproject.Web 
{ 

    public class CustomTable 
    { 
     [Key] 
     public string EntryId { get; set; } 
     public int closed_Time { get; set; } 
    } 
} 

(2) IncidentService.cs에 걸러 :

public IQueryable<CustomTable> GetJoined() 
{ 
    return (from i in this.ObjectContext.Events     
      join p in this.ObjectContext.TimeStamps p 
      on i.Entry_ID equals p.Entry_ID 
      select new CustomTable 
      { 
       EntryId = i.Entry_ID, 
       closed_Time = p.Closed_TIME 
      }); 
} 

Mypage.xaml.cs에 3 추가

나는이 다른 사람을 도움이되기를 바랍니다
public MyPage() 
{ 
    InitializeComponent(); 


    this.dataGrid1.ItemsSource = _IncidentContext.CustomTables; 
    _IncidentContext.Load(_IncidentContext.GetJoinedQuery()); 



    DataGridTextColumn entry = new DataGridTextColumn(); 
    entry.Binding = new System.Windows.Data.Binding("EntryId"); 
    entry.Header = "Entry Id"; 

    DataGridTextColumn closed = new DataGridTextColumn(); 
    closed.Binding = new System.Windows.Data.Binding("closed_Time"); 
    closed.Header = "Closed Time"; 

    dataGrid1.Columns.Add(entry); 
    dataGrid1.Columns.Add(closed); 

} 

같은 문제로 3 일 동안이 솔루션을 사용했습니다.