使用Odata获取大量数据 [英] Using Odata to get huge amount of data

查看:209
本文介绍了使用Odata获取大量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据源提供者:

I have a data source provider :

public class DSProvider
    {
        public IQueryable<Product> Products
        {
            get
            {
                return _repo.Products.AsQueryable();
            }
        }
}

上例中的存储库当前从数据库获取所有(产品)记录,然后应用过滤器,如果您从网站获得50000请求/秒,这听起来不正确.如何将存储库限制为只是从DB返回所需的信息,而没有将服务转换为紧密耦合的请求选项,即与您尝试使用oData实现的相反吗?

The repository in the above example currently gets ALL the records (of Products) from DB and then applies the filters, this just does not sound right if you had 50000 requests/sec from a website.How can you limit the repository to just return required info from DB without converting the service to a tightly coupled request option i.e. opposite of what you try to achieve by using oData?

总而言之,我想知道是否有可能在用户提供的oData选项上查询数据库,以便我的请求不必总是获取所有产品,然后应用oData过滤器.

So to summarize I would like to know if its possible to query the DB on the oData options supplied by the user so that my request does not always have to get all products and then apply filters of oData.

推荐答案

我做了一个小的POC之后发现,实体框架负责根据请求构建动态查询.

I found out after doing a small POC that Entity framework takes care of building dynamic query based on the request.

这篇关于使用Odata获取大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆