Silverlight RIA DomainService 表中有 200 万行

发布于 2024-12-01 06:03:47 字数 350 浏览 0 评论 0 原文

我正在做一个从 oracle 数据库读取数据的项目。我使用了 Silverlight RIA 和自动生成的 DomainService,因为我不太关心结构,因为我只担心显示数据。

我的问题是,当我使用 XAML 中的域数据源并使用 fiddler 调试 WCF 服务及其调用时,用户帐户表中的第一组数据包含 200 万行,并且 DomainService 超时。

现在我尝试将服务超时增加到 20 分钟,但仍然无济于事,我收到错误:

查询“GETUA_USERACCOUNTS”的加载操作失败。 http 请求已超过分配的超时

另外,在我使用的总共 9 个表中,有 3 个表约有 200 万行,解决此问题的最佳方法是什么?

I'm doing a project that reads from an oracle database. I have used Silverlight RIA, and autogenerated DomainService since I'm not too concerned about structuring as I only worry about displaying the data.

My question is, that when I use the domaindatasource from the XAML, and use fiddler for debugging the WCF service and its calls, the first set of data from the table of useraccounts contains 2 million rows, and the DomainService times out.

Now I have tried increasing the timeout of the service to 20 mins, but still no avail, I get the error:

Load operation failed for query "GETUA_USERACCOUNTS". The http request to has exceeded the alloted timeout

Also out of the total 9 tables that I use, 3 tables have around 2 million rows, what would be the best method to approach this problem?

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

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

发布评论

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

评论(4

巨坚强 2024-12-08 06:03:47

使用 ToTraceString 方法...

http:// msdn.microsoft.com/en-us/library/system.data.objects.objectquery.totracestring.aspx

...或 Oracle 分析工具来确定正在使用的 SQL 语句并确认它是否需要很久执行。

使用查询优化技术(例如添加索引)来加快速度。

或者,编写一个存储过程,以更有效的方式返回所需的结果。

Use the ToTraceString method...

http://msdn.microsoft.com/en-us/library/system.data.objects.objectquery.totracestring.aspx

...or an Oracle profiling tool to determine the SQL statement that is being used and confirm that it takes a long time to execute.

Use query optimization techniques such as adding indexes to speed it up.

Alternatively, write a stored procedure that returns the required result in a more efficient manner.

过期情话 2024-12-08 06:03:47

之前,在服务器上进行数据过滤/处理

public IQueriable<UserDTO> GetUserAccountDetails(string UserID)
{
    DataSet oneBazillionRows = SQLServer.GetAllUserRows();

    // LINQ to the rescue
    return from user in oneBillionRows
           where user.ID = UserID;
}

要继续 TomTom 离开的地方,Red 询问,在返回结果(伪代码)和消费者

public void GetUserInfo()
{
    ServiceContext context = new ServiceContext();
    context.Load<UserDTO>(ServiceContext.GetUserAccountDetailsQuery(), load =>
    {
        // do some work here
        //like signalling the call is complete
        // or storing the data in your View Model
    }, null);
}

:然后,你的消费者将只收到一个数据行。基本形式如下:

public IQueriable<ReturnType> WebService(Parameter parameter, ...)
{
    // Do all your work here, return minimal results
}

考虑:服务器总是比您的客户端计算机强大得多。让它完成过滤/排序/预处理结果的所有工作,并让它交出最少的数据。您会发现您的 RIA 实施变得更加敏捷。

To continue where TomTom left off, and Red asked, do your data filtering / processing on the server, before returning the results (Psuedocode)

public IQueriable<UserDTO> GetUserAccountDetails(string UserID)
{
    DataSet oneBazillionRows = SQLServer.GetAllUserRows();

    // LINQ to the rescue
    return from user in oneBillionRows
           where user.ID = UserID;
}

and your comsumer:

public void GetUserInfo()
{
    ServiceContext context = new ServiceContext();
    context.Load<UserDTO>(ServiceContext.GetUserAccountDetailsQuery(), load =>
    {
        // do some work here
        //like signalling the call is complete
        // or storing the data in your View Model
    }, null);
}

You consumer will then only recieve the one data row. The basic form is like so:

public IQueriable<ReturnType> WebService(Parameter parameter, ...)
{
    // Do all your work here, return minimal results
}

Consider: Invariably, the sever is going to be a lot beefier than your client machine. Let it do all the work of filtering / sorting / preprocessing results, and have it hand over minimal data. You will find your RIA implementations become much more snappy.

梦途 2024-12-08 06:03:47

您应该使用 DataPager,请参阅此处: http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Services-Part-4-Adding-a-DomainDataSource.aspx

<navigation:Page x:Class="WebAdministrationTool.ManageUsers" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ria="clr-namespace:System.Windows.Controls;assembly=System.Windows.Ria.Controls"
    xmlns:local="..."
    xmlns:validation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm">

    <Grid x:Name="LayoutRoot">

        <data:DataGrid x:Name="UsersGrid" 
                       IsReadOnly="True" 
                       AutoGenerateColumns="True"
                       ItemsSource="{Binding Data, ElementName=MyDataSource}" />

        <validation:DataPager x:Name="UsersPager"
                              PageSize="10" 
                              Source="{Binding Data, ElementName=MyDataSource}" />

        <ria:DomainDataSource x:Name="MyDataSource" LoadMethodName="LoadHugeAmountOfRows">
            <ria:DomainDataSource.DomainContext>
                <local:MyDomainContext />
            </ria:DomainDataSource.DomainContext>
        </ria:DomainDataSource>

    </Grid>

</navigation:Page>

You should use a DataPager, see here: http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Services-Part-4-Adding-a-DomainDataSource.aspx

<navigation:Page x:Class="WebAdministrationTool.ManageUsers" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ria="clr-namespace:System.Windows.Controls;assembly=System.Windows.Ria.Controls"
    xmlns:local="..."
    xmlns:validation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm">

    <Grid x:Name="LayoutRoot">

        <data:DataGrid x:Name="UsersGrid" 
                       IsReadOnly="True" 
                       AutoGenerateColumns="True"
                       ItemsSource="{Binding Data, ElementName=MyDataSource}" />

        <validation:DataPager x:Name="UsersPager"
                              PageSize="10" 
                              Source="{Binding Data, ElementName=MyDataSource}" />

        <ria:DomainDataSource x:Name="MyDataSource" LoadMethodName="LoadHugeAmountOfRows">
            <ria:DomainDataSource.DomainContext>
                <local:MyDomainContext />
            </ria:DomainDataSource.DomainContext>
        </ria:DomainDataSource>

    </Grid>

</navigation:Page>
秉烛思 2024-12-08 06:03:47

我遇到了类似的问题,为了处理这个问题,我在数据库上创建了存储过程来完成工作,并且只返回我需要的信息。关于向 RIA 添加存储过程的信息并不多,但这里是我所知道的工作原理的一个镜头。

  1. 创建存储过程
  2. 在项目中更新数据库模型,以将存储过程包含
  3. 在模型浏览器中,右键单击并添加函数导入。在这里,您可以命名并决定如何返回数据(让自己轻松并尝试返回 DomainService.metadata.cs 文件中已有的对象),
  4. 如果创建新的返回对象,请将其添加到您的 DomainService.metadata.cs 文件
  5. < p>在您的域服务中添加一个返回结果列表的公共方法。

    public IQueryable; UpdateFWCUserWithUserProfileID(int userProfileID, int fwcUserID)
    {
       返回 this.ObjectContext.UpdateFWCUserWithUserProfileID(userProfileID, fwcUserID).AsQueryable();
    }
    
  6. 构建您的项目并根据需要从代码隐藏中调用方法

    FWCDomainContext context = new FWCDomainContext();
    context.Load(context.UpdateFWCUserWithUserProfileIDQuery(num1, num2), 已完成, null);
    

I had similar issue and to handle this i created stored procedures on my database to do the work and only spit back the information i needed. There is not a lot of info on adding stored procedures to RIA but here is a shot on what i know works.

  1. create your stored procedure
  2. update your Database Model in your project to include the stored procedure
  3. in Model Browser right click and add function import. here you get to name and decide how the data is returned (make it easy on yourself and try to return an object already in your DomainService.metadata.cs file)
  4. if creating new return object add it to your DomainService.metadata.cs file
  5. in your domain service add a public method that returns the result list.

    public IQueryable<FWCUser> UpdateFWCUserWithUserProfileID(int userProfileID, int fwcUserID)
    {
       return this.ObjectContext.UpdateFWCUserWithUserProfileID(userProfileID, fwcUserID).AsQueryable();
    }
    
  6. build your project and call the method as needed from code behind

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