I have two classes:
public class classA
{
public string keyA {get; set;}
public string propAA {get; set;}
public string propAB {get; set;}
public string propAC {get; set;}
}
public class classB
{
public string keyB {get; set;}
public string foreignkeyA {get; set;}
public string propBA {get; set;}
public string propBB {get; set;}
public string propBC {get; set;}
}
If I do a join between them..
var query = db.ClasseA.
Join(db.ClasseB, a => a.keyA, b => b.foreignkeyA,
(ca, cb) => new { ca, cb })
.Where(q => q.cb.propBC == 'some value')
.Select();
The result is a combination (list) of classA and classB objects.
But, I need that the result is only a list of class A .
Something like:
List<classA> query = db.ClasseA.
Join(db.ClasseB, a => a.keyA, b => b.foreignkeyA,
(ca, cb) => new { ca, cb })
.Where(q => q.cb.propBC == 'some value')
.Select(????);
How can I do that??
One example
var query = from obj1 in db.Object1
join obj2 in db.Object2 on obj1.key equals obj2.somekey
where obj1.something = "something"
select obj1
This will join the two but only bring back obj1 items
reference: https://msdn.microsoft.com/en-us/library/bb311040.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.