重用IQueryable表达式

时间:2018-02-28 03:38:42

标签: c# entity-framework entity-framework-core

我有一个带有可查询表达式的方法。是否可以在不同的函数中重用该函数,传入一个可查询的?

public static IQueryable<IProduct> Product(IQueryable<IProduct> dbSet)
{
    var result = ProductLite(dbSet)
        .Include(prd => prd.GraphicItems)
            .ThenInclude(itm => itm.Graphic)
                .ThenInclude(gfx => gfx.Items)
        .Include(prd => prd.GraphicItems)
            .ThenInclude(gfx => gfx.Culture)
                .ThenInclude(cult => cult.Items)
        .Include(prd => prd.Feedback)
            .ThenInclude(item => item.Culture)
        .Include(prd => prd.Feedback)
            .ThenInclude(feed => feed.Customer)
                .ThenInclude(cust => cust.Culture)
        .Include(prd => prd.Feedback)
            .ThenInclude(feed => feed.Votes)
                .ThenInclude(vote => vote.Customer)
        .Include(prd => prd.Stock)
        .Include(prd => prd.Campaigns)
            .ThenInclude(camp => camp.Campaign)
        .Include(prd => prd.Campaigns)
            .ThenInclude(camp => camp.Culture)
                .ThenInclude(cult => cult.Items)
                    .ThenInclude(itm => itm.Culture)
        .Include(prd => prd.SubscriptionItems)
            .ThenInclude(sub => sub.Culture)
        .Include(prd => prd.Links)
        .Include(prd => prd.Meta);

    return result;
}

我需要重用Product函数的函数:

public static IQueryable<IStore> Store(IQueryable<IStore> dbSet)
{
    var result = StoreLite(dbSet)
        .Include(str => str.Categorys)
            .ThenInclude(cat => cat.Products)
}

0 个答案:

没有答案