1
Expression<Func<Account, IEnumerable<Attachment>>> attachments =  t => attachmentBuilder.Populate("COMPANYNAME", t.AccountID.ToString());

 var q = cxt.Accounts.Select(e => new
 {
    AccountID = e.AccountID,
        Description = e.AccountDescription,
 });

What I ideally want is to Join attachments Expression (results) to q (accounts- IEnumerable) so I can filter by AccountID which is dynamically passed from UI "t.AccountID.ToString()" I dont want to use sub query as I have loads of attachments so I am looking for a more Join type solution with Dynamic Linq and Expression trees with passing the account id dynamically. Thanks,

svick
  • 236,525
  • 50
  • 385
  • 514
chugh97
  • 9,602
  • 25
  • 89
  • 136
  • 1
    I really don't understand what you're asking. Maybe an example of what the final expression should look like would help. – svick May 15 '13 at 14:09
  • @svick In a normal case say I have an attachments table and a accounts table, I can make a straight forward join on say acctionid column and do a where accountid on the query to get the account with all attachments associated with it filtered by accountid passed. – chugh97 May 15 '13 at 14:17
  • @svick The problem I have having is I have a business object method which returns attachments for an account attachmentBuilder.Populate passes company which is hardcoded for simplicity and accountid passed dynamically. As accountid is not know till its passed I need a join between the return of this method and the accounts collection filtered by accountid passed. Dont ask me why as I am told to do it this way..I know it sounds very crazy – chugh97 May 15 '13 at 14:19

0 Answers0