Linq交叉和除外

时间:2016-05-22 20:45:59

标签: c# linq intersect except

我有两节课:

public class Customer
{
    public string FirstName { get; set; }

    public string LastName { get; set; }

    public bool isActif { get; set; }

    public Product[] Product { get; set; }
}

public class Product
{
    public string Id { get; set; }
}

还有两个例子:

var Customer1 = new Customer[]
{
    new Customer()
    {
        FirstName = "FirstName1",
        LastName = "LastName1",
        isActif = true,
        Product = new Product[]
        {
            new Product()
            {
                Id = "2",
                Date = DateTime.Now.Date
            }
        }
    },
    new Customer()
    {
        FirstName = "FirstName2",
        LastName = "LastName2",
        isActif = false,
        Product = new Product[]
        {
            new Product()
            {
                Id = "3",
                Date = DateTime.Now.Date
            }
        }
    }
};

var Customer2 = new Customer[]
{
    new Customer()
    {
        FirstName = "FirstName1",
        LastName = "LastName1",
        isActif = true,
        Product = new Product[]
        {
            new Product()
            {
                Id = "2",
                Date = DateTime.Now.Date
            }
        }
    }
};

我希望通过LastName中的贡献来获得两个实例的交集。如果不在我的类中实现Equals()和GetHashCode()方法,是否可以这样做?我有很多属性。

另外,我想知道第一个权限而不是第二个权限的客户。反过来说

0 个答案:

没有答案