有人在 .NET RIA DomainDataService 和 POCO 方面取得过成功吗?

发布于 2024-07-25 23:37:03 字数 1069 浏览 4 评论 0原文

我有这个工作并获取数据。 但是,每次我寻呼时,它都会调用 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");
}

I have this working and getting data. However, everytime I page it calls the GetAllWebExceptions, which gets all of the web exceptions records from the database. How should paging be implemented? I've only seen examples with EntityFrameworks. Does anyone have a good example using the data source with POCO or is that still to come?

 <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" />

in the service:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半世晨晓 2024-08-01 23:37:03

您当然应该能够使用 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");
    }
}

希望有帮助...

You should certainly be able to use a POCO class. However your query method needs to reference it by returning a generic IEnumerable, so the rest of the system knows at compile time of your type.

The requirement is your POCO class must have some notion of identity, made up of one or more members that are marked with the [Key] metadata attribute.

For example:

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");
    }
}

Hope that helps...

↘紸啶 2024-08-01 23:37:03

看看 Brad Abrams 的精彩演练 将 POCO 与 RIA 服务结合使用

Take a look at Brad Abrams excellent walk-through on using POCO with RIA Services

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文