我有一个方法,它从两个以上的表中返回数据,这些表之间没有映射关系。
Public class UserInfo
{
public string UserName {get; set;} //UserTable
public string UserMail { get; set;} //UserTable
public string ServiceName {get; set;} //ServiceTable
public string Specialization {get; set;} //SpecializationTable
}
public UserInfo fetchUserInfo(int userId)
{
}
我能获得这些唱片的最佳方式是什么ServiceName和Specialization?
我建议您使用"join"来解决这个问题。
这将是类似的。
from userTable in SBDB.UserTable
join serviceTable in SBDB.ServiceTable on userTable.ID equals serviceTable.ID
join specializationTable in SBDB.SpecializationTable on .....
where ....
select new PO_Master {
UserName = usrInfo.UserName;
UserMail = usrInfo.UserEmail;
ServiceName = serviceTable.ServiceName;// need to get this from service table
Specialization = specializationTable.Specialization;// need to get this from specialization table
}
希望得到帮助。