2009-07-02 2 views
2

나는이 작업을하고 데이터를 얻습니다. 그러나 매번 I 페이지를 호출하면 GetAllWebExceptions가 호출되어 데이터베이스에서 웹 예외 레코드를 모두 가져옵니다. 페이징은 어떻게 구현되어야합니까? EntityFrameworks에서만 예제를 보았습니다. 누구든지 POCO와 함께 데이터 소스를 사용하는 좋은 예가 있습니까? 서비스에누구나 .NET RIA DomainDataService 및 POCO로 성공 했습니까?

<Grid x:Name="LayoutRoot" Background="White"> 
     <ria:DomainDataSource x:Name="ErrorLogDataSource" 
           LoadMethodName="GetAllWebExceptions"> 
      <ria:DomainDataSource.DomainContext> 
       <services:CMSContext /> 
      </ria:DomainDataSource.DomainContext> 
     </ria:DomainDataSource> 
     <data:DataGrid x:Name="DataGridExceptions" ItemsSource="{Binding ElementName=ErrorLogDataSource, Path=Data}" 
         AutoGenerateColumns="True"> 
     </data:DataGrid> 
     <dataControls:DataPager Source="{Binding Data, ElementName=ErrorLogDataSource}" 
           PageSize="20" /> 

:

 
[Query(PreserveName = true)] 
public IEnumerable GetAllWebExceptions() 
{ 
    return WebException.SelectAll("DATECREATED DESC"); 
} 
+0

에 브래드 에이 브람스 우수한 워크를 통해 살펴 보자 : HTTP : //silverlight.net/forums/p/100818/244081.aspx#244081 – Aligned

답변

1

당신은 확실히 POCO 클래스를 사용할 수 있어야합니다. 그러나 쿼리 메서드는 일반 IEnumerable을 반환하여이를 참조해야하므로 나머지 시스템은 해당 형식의 컴파일 시간을 알고 있습니다.

귀하의 POCO 클래스는 [Key] 메타 데이터 속성으로 표시된 하나 이상의 회원으로 구성된 신원 정보를 가져야합니다. 예를 들어

:

public class WebException { 

    [Key] 
    string id; 
    // Or it could be a DateTime if you use time of occurrence as the key, 
    // or anything else that is unique. 

    // ... 
    // Other members 
} 

public class ErrorManager : DomainService { 

    public IEnumerable<WebException> GetAllWebExceptions() { 
     return WebException.SelectAll("DATECREATED DESC"); 
    } 
} 

희망하는 데 도움이 ...