相关疑难解决方法(0)

使用LINQ从List <T>中删除元素

假设我有LINQ查询,例如:

var authors = from x in authorsList
              where x.firstname == "Bob"
              select x;
Run Code Online (Sandbox Code Playgroud)

鉴于它authorsList是类型List<Author>,我如何删除查询返回的Author元素?authorsListauthors

或者换句话说,如何删除所有名字等于Bob的名字authorsList

注意:这是用于问题目的的简化示例.

.net c# linq list

633
推荐指数
12
解决办法
57万
查看次数

linq到实体的内部联接

我有一个名为Customer的实体,它有三个属性:

public class Customer {
    public virtual Guid CompanyId;
    public virtual long Id;
    public virtual string Name;
}
Run Code Online (Sandbox Code Playgroud)

我还有一个名为Splitting的实体,它有三个属性:

public class Splitting {
    public virtual long CustomerId;
    public virtual long Id;
    public virtual string Name;
}
Run Code Online (Sandbox Code Playgroud)

现在我需要编写一个获取companyId和customerId的方法.该方法应返回与companyId中特定customerId相关的拆分列表.像这样的东西:

public IList<Splitting> get(Guid companyId, long customrId) {    
    var res=from s in Splitting 
            from c in Customer 
            ...... how to continue?

    return res.ToList();
}
Run Code Online (Sandbox Code Playgroud)

.net c# linq-to-entities

28
推荐指数
2
解决办法
9万
查看次数

标签 统计

.net ×2

c# ×2

linq ×1

linq-to-entities ×1

list ×1