小编use*_*035的帖子

将列表转换为特定属性的逗号分隔字符串的最简单方法?

我有一个自定义对象列表,实际上这些是我存储在IEnumerable集合中的实体.我想将列表转换为逗号分隔的字符串,但我只想要一个特定的属性,如何使用自定义对象列表中的特定属性构建逗号分隔的字符串?

我知道我可以通过使用a来构建逗号分隔列表,"Foreach / For (int i .... " 但我认为有一个简单而且更好的方法,那么这将是多么简单的方法?

这是我的清单

IEnumerable<BAL.Category> categories = chklCategories.CheckedItems.Cast<BAL.Category>();
            //Category object has a property called Name , I want the list from that property
Run Code Online (Sandbox Code Playgroud)

.net c# linq entity-framework

6
推荐指数
1
解决办法
6724
查看次数

如何从一个人的名单中查询大孩子?

在下面的代码中,我已经解释了我想要的内容,请有人帮我解决这个问题.

public class Person
{
    public IEnumerable<Child> Children { get; set; } 
}

public class Child
{
    public IEnumerable<GrandChild> GrandChildren { get; set; } 
} 

public class SearchingClass
{
    public void Search()
    {
        IEnumerable<Person> persons = MyPersons;
        IEnumerable<GrandChild> grandChildren = MyGrandChildren

        //Now I want only the Grand Children who are grand children of persons in Persons List 
        //How can I write a query for this ? 
    } 
} 
Run Code Online (Sandbox Code Playgroud)

.net c# linq entity-framework iqueryable

2
推荐指数
1
解决办法
96
查看次数

标签 统计

.net ×2

c# ×2

entity-framework ×2

linq ×2

iqueryable ×1