문제

I have this sql expression and I want to convert it into a code syntax using entity framework or linq

select [Key],name from products where [Key] not in (select distinct parent from products where parent is not null)
도움이 되었습니까?

해결책

Try this one, may be it can help you

var p = products.Where(p => p.parent != null).select(p=>p.parent).Distinct();

var pro = products.Where(p => !p.Contains(p.Key))
                   .Select(p => new { ProKey = p.Key, ProName.Name }); 

May be its will work, and still you having problem that let me know...

다른 팁

I think this will work.

var parents = products.Where(p => p.parent != null).Distinct();

var products = products.Where(p => !parents.Contains(p.Key))
                       .Select(p => new { p.Key, p.Name }); 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top