我有这个工作并获取数据。但是,每次我调页时都会调用GetAllWebExceptions,它会从数据库中获取所有Web异常记录。如何实现分页?我只看过EntityFrameworks的例子。有没有人有一个很好的例子使用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 :(得分: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");
}
}
希望有帮助...
答案 1 :(得分:0)