-6

我有 4 个需要加入的列表

public class Person
{
    public int personid { get; set; }
    public string fname { get; set; }
    public string lname { get; set; }
}

public class Department
{
    public int depid { get; set; }
    public string departmentname { get; set; }
}

public class Group
{
    public int groupid { get; set; }
    public int depid { get; set; }
    public string groupname { get; set; }
}

public class UploadFile
{
    public int fileid { get; set; }
    public int personid { get; set; }
    public int groupid{ get; set; }
    public string filename { get; set; }
}

List<Person> Persons=GetPersons();
List<Department> departmentlist=getDepartments();
List<Group> grouplist=getgroups();
List<UploadFile> filelist=getFiles();

我需要一个像这样的输出:

fileid fname 文件名路径                         

1 个样本名 Mydoc 部门名+">"+组名
4

1 回答 1

1

您可以使用Zip

List persons=GetPersons();
List departmentlist=getDepartments();
List grouplist=getgroups();
List filelist=getFiles();

var result = persons.Zip(departmentlist, (person, department) => person.fname + " " + department.departmentname)
                    .Zip(grouplist, (personAndDepartment, group) => personAndDepartment + " " + group.groupName);

// etc ...
于 2012-04-12T08:54:56.410 回答