Case 1:
Code: Select all
db.Set<RecordOne>()
.Select(x => x.RecordManyList.Select(y => y.str).FirstOrDefault() ?? "7")
.ToListAsync()
Code: Select all
SELECT COALESCE(SELECT y.string
FROM record_many y
WHERE x.id = y.record_one_id
LIMIT 1, '7')
FROM record_one x
Code: Select all
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT y.string .....
Code: Select all
db.Set<RecordOne>()
.Select(x => new { x.Id, someField = x.RecordManyList.Any() })
.ToListAsync()
Code: Select all
SELECT x.id, SELECT CASE
WHEN EXISTS (
SELECT 1
FROM record_many r
WHERE x.id = r.record_one_id)
THEN 1 ELSE 0
END AS someField
FROM record_one x
Code: Select all
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT CASE .....