开发者

How to write simple Where Clause for dynamic filtering in linq when we use groups in join

开发者 https://www.devze.com 2022-12-17 20:06 出处:网络
I have simple search page i want to filter the results. var TransactionStats = from trans in context.ProductTransactionSet.Include(\"SPL\")

I have simple search page i want to filter the results.

var TransactionStats = from trans in context.ProductTransactionSet.Include("SPL")
    select new
    {
        trans.InvoiceNo,         
        ProductGroup = from tranline in trans.ProductTransactionLines
            group tranline by tranline.ProductTransaction.TransactionID
            into ProductGroupDetil
            select new
            {
              开发者_JAVA百科  TransactionDateTime = ProductGroupDetil.Select
                    (Content => Content.TransactionDateTime)
            }
    };

I want to use TransactionDateTime in where clause when required.

if (_FilterCrieteria.DateFrom.HasValue)
{
    TransactionStats.Where
    (
        a => a.ProductGroup.Where
            (
                dt => dt.DateofTransaction >= _FilterCrieteria.DateFrom &&
                    dt.DateofTransaction >= _FilterCrieteria.DateFrom
            )
    )
}

Can any one correct the syntax?


The third row in your second code block should probably read:

    TransactionStats = TransactionStats.Where
0

精彩评论

暂无评论...
验证码 换一张
取 消