0

I want to Use two field in my join predicate in linq.How can i add the other field ?

    var Result = from Period in context.PeriodCosts
                 join Name in context.Name on Period.ID equals Name.PeriodID 
                /*"Problem is here ==> */and   
                 Period.CCID equals Name.CCID"
                 select Name;

2 Answers 2

5

Use anonymous type:

var Result = from Period in context.PeriodCosts
             join Name in context.Name
                 on new { ID = Period.ID, CCID = Period.CCID }
                 equals new { ID = Name.PeriodID, CCID = Name.CCID }
             Period.CCID equals Name.CCID"
             select Name;
Sign up to request clarification or add additional context in comments.

Comments

1

Try the below

 var Result = from Period in context.PeriodCosts
             join Name in context.Name on 
             new{Period.ID, Period.CCID} equals new { Name.PeriodID, Name.CCID}               
             select Name;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.