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

Posted by malik on Stack Overflow See other posts from Stack Overflow or by malik
Published on 2010-01-25T05:32:09Z Indexed on 2010/04/26 22:13 UTC
Read the original article Hit count: 178

Filed under:
|

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
            {
                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?

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about LINQ