Home

why linqpad gets all relation table even if ı don't call them

var x = Advertisements.Include(a=>a.Product).ThenInclude(x=>x.Province).OrderBy(x=>x.Id).FirstOrDefault();

Console.WriteLine($"Ad Id ={x.Id} ----- ProdId = {x.Product.Id} ---- Province Name: {x.Product.Province.Name} ---------- ");

Console.WriteLine($"Ad Id ={x.Id} ----- CreatedBy = {x.CreatedBy.Id} ---- CreatedBy Name: {x.CreatedBy.FirstName} ---------- ");

var y = (from ad in Advertisements
join pr in Products on ad.ProductId equals pr.Id
join p in Provinces on pr.ProvinceId equals p.Id
orderby ad.Id
select new {ad,pr,p}).FirstOrDefault();

Console.WriteLine($"Ad Id ={y.ad.Id} ----- ProdId = {y.pr.Id} ---- Province Name: {y.p.Name} ---------- ");

Console.WriteLine($"Ad Id ={y.ad.Id} ----- CreatedBy = {y.ad.CreatedBy.Id} ---- CreatedBy Name: {y.ad.CreatedBy.FirstName} ---------- ");

why am ı getting all results perfectly? becouse both query didtnt call createsBy which related to advertisement , why second console's work linqpad. They dont work vs code or Vs

Sign In or Register to comment.