पर कैसे चालू करें मैं अपने linq क्वेरी में बाद में आलसी लोड के लिए एक निश्चित चयन आइटम बनाना चाहता हूं। यहाँ मेरी क्वेरीइस LINQ क्वेरी को आलसी लोडिंग
var posts = from p in context.post
where p.post_isdeleted == false && p.post_parentid == null
select new
{
p.post_date,
p.post_id,
p.post_titleslug,
p.post_votecount,
FavoriteCount = context.PostVotes.Where(x => x.PostVote_postid == p.post_id).Count() //this should load latter
};
मैं चयन क्वेरी में FavoriteCount आइटम हटा दिया है और बाद में जोड़ा कुछ शर्तों के आधार बा को यह चाहते हैं। यहां जिस तरह से मुझे आलसी लोड किया गया है
if (GetFavoriteInfo)
{
posts = posts.Select(x => new { FavoriteCount = context.PostVotes.Where(y => y.PostVote_postid == x.post_id).Count() });
}
मुझे उपरोक्त क्वेरी के साथ एक वाक्यविन्यास त्रुटि मिल रही है। मैं इस
मैं this..Would पर एक नौसिखिया आप reassignments का एक उदाहरण है कर रहा हूँ? – Luke101
@ Luke101: उदाहरण अपडेट किया गया। – tzaman