public async Task <IActionResult> Search(string name) { var listP = from Phone in _db.Phones.AsNoTracking().Where(x => x.PhoneName.Contains(name)) join osName in _db.OS on Phone.OSID equals osName.OSID into RequestPhone from m in RequestPhone.DefaultIfEmpty() select new { PhoneName = Phone.PhoneName, OsName = m.OsName, Battery = Phone.PhoneBattery.Volume }; return(Ok(await listP.AsNoTracking().ToListAsync())); }
public async Task <IActionResult> GetPhoneByJoin() { var result = from Phone in _db.Phones.AsNoTracking() join osName in _db.OS on Phone.OSID equals osName.OSID into RequestPhone from m in RequestPhone.DefaultIfEmpty() select new { PhoneName = Phone.PhoneName, OsName = m.OsName, Battery = Phone.PhoneBattery.Volume, Price = Phone.Price }; return(Ok(await result.AsNoTracking().ToListAsync())); }