Click here to Skip to main content
15,889,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have three table

public class UserDetail
   {
       public long UserId { get; set; }
       public Nullable<byte> State { get; set; }
       public Nullable<int> City { get; set; }
       public Nullable<int> Location { get; set; }
       public string CompleteAddress { get; set; }
       public string Father { get; set; }

   }


public class ClassDetail
   {
       public int CId { get; set; }
       public Nullable<int> Classid { get; set; }
       public Nullable<int> UserId { get; set; }
   }



public class SubjectDetail
   {
       public int SId { get; set; }
       public Nullable<int> Subjectid { get; set; }
       public Nullable<long> CId { get; set; }
   }




User fill our information and select multiple class and multiple subject. subject are select on the behalf of class. means one class contain multiple subject
how i got this type of result like
How to create entity framework query.

UserId  State  City  Location  CompleteAddress  ClassName  Subject
1       ABC    C1    L1         xyz             10st        Hindi,English
1       ABC    C1    L1         xyz             12st        Science,English,Math


What I have tried:

How to create entity framework query?
Posted
Updated 19-Apr-17 0:09am
v2
Comments
Maciej Los 19-Apr-17 4:33am    
At this moment a Subject doesn't contain property which returns string (Hindi, English, etc.)

What have you tried? Where are you stuck?
shipalis 19-Apr-17 4:52am    
Subject and Class two other table which have content property Subject and Class as string
exp.

public ClassDetail
{
public Nullable<int> Classid { get; set; }
public string Class { get; set; }
}

public SubjectDetail
{
public Nullable<int> Subjectid { get; set; }
public string Subject{ get; set; }
}

Cast the result to an Array and use the Join method.
 
Share this answer
 
Comments
Maciej Los 19-Apr-17 4:30am    
There's no need to "cast the result to an array", becuase Join method acceppts IEnumerable(Of T).
Check this!
You can create a raw SQL query and use FOR XML clause - see here:
FOR XML (SQL Server)[^]
 
Share this answer
 
Comments
Loki1942 18-Dec-17 6:00am    
you could have just kept quiet instead of posting this. The questions was related to ENTITY FRAMEWORK. Your answer is related to IEnumerable
NightWizzard 18-Dec-17 7:11am    
If you don't understand what SQL is, you shouldn't post such comments. Entity Framework can be used with pure SQL - even if you're not able to translate the article to this question I don't know, why you associate it with IEnumerable?!
Loki1942 18-Dec-17 7:19am    
again....the question read "How to get list with comma separated *_using_* entity framework.
NightWizzard 18-Dec-17 12:48pm    
As your profile shows, you never gave any helpful answer here nore published any kind of tip or solution to others. But you downvote a solution you don't understand and acting up like a teacher. Don't you have better things to do than getting on my nerves on a question that is 8 month old and nobody had a problem with the solutions until you came along. Go and annoy someone else!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900