TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ravi sharma
NA
87
16.8k
How to check child table contains any item from array
Sep 2 2016 6:38 AM
Hi,
I have two tables Recommendation and RecommendationMemberDetails. Both table contains MemberId.
Recommendation table contains my id as MemberId and RecommendationMemberDetail table will contain other peoples Id as MemberId with recommendationId.
Recommendation
----------------------------
RecommendationId (PK)
MemberId
RecommendationMemberDetail
-------------------------------------------
Id
RecommendationId
MemberId
Now I will select multiple contact from Contact list and I need to fetch such Recommendation Where MemberId of Recommendation or RecommendationMemberDetails contains MemberId from contactlist.
Following is the query.
var data1 = _context.Recommendations.Where(x => listMembers.Contains(x.MemberId) || (x.RecommendationMemberDetail.Count() > 0 && listMembers.Contains(x.RecommendationMemberDetail.Select(y => y.MemberId).ToString())) && x.CSM_Approve != "p");
Please suggest.
Reply
Answers (
1
)
Sql to linq Converion of a query
select in Join experssion