如何使用实体框架分隔逗号分隔列表。 [英] How to get list with comma separated using entity framework.
本文介绍了如何使用实体框架分隔逗号分隔列表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有三张桌子
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?
推荐答案
将结果转换为数组
并使用Join
方法。
Cast the result to anArray
and use theJoin
method.
您可以创建原始SQL查询并使用FOR XML子句 - 请参阅:
FOR XML(SQL Server) [ ^ ]
You can create a raw SQL query and use FOR XML clause - see here:
FOR XML (SQL Server)[^]
这篇关于如何使用实体框架分隔逗号分隔列表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文