I want to write a select between two table that have relation. I use this code but i get no result. Please advise me
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
};
}
I think you might be looking for a join instead, regardless you should be getting results if you have matching rows in the database. Also currently you are not doing anything with the results.
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);
}
}
精彩评论