SELECT t1.*,(SELECT "a" from t2 where t1.id=t2.aid) as t3
FROM
t1
linq主从表联合查询:
//var books = from s in _bookContext.Books
// select new
// {
// id = s.Id,
// title = s.Title,
// image = _bookContext.Images.FirstOrDefault(m => m.BookId == s.Id).Image1
// };
var books = from s in _bookContext.Books
let image1 = (from t in _bookContext.Images where t.BookId == s.Id select t).FirstOrDefault()
select new
{
id = s.Id,
title = s.Title,
image = image1.Image1
};
以上为土办法,有高端方法请留言,谢谢