我想在两个有关系的表之间写一个select。 我使用这段代码,但没有结果。 请告诉我
using (doctorEntities de = new doctorEntities())
{
var select = from tibase in de.Table_infobase_print
from tidetail in de.Table_infodetail_print
where tibase.ID == tidetail.ID_infobase
select new
{
tidetail.services_discription,tidetail.price,tibase.folder_code
};
}
答案 0 :(得分:1)
我认为您可能正在寻找加入,无论您是否应该在数据库中有匹配的行时获得结果。目前你还没有对结果做任何事情。
using (doctorEntities de = new doctorEntities())
{
var results = from tibase in de.Table_infobase_print
join tidetail in de.Table_infodetail_print
on tibase.ID equals tidetail.ID_infobase
select new
{
tidetail.services_discription,
tidetail.price,
tibase.folder_code
};
foreach(var result in results)
{
Console.WriteLine("Service description: " + result.services_discription);
}
}