Hi Friends,
Please help me for below query:
how to apply join ???like i want this type output query
select * from CostCentre1 as c left Outer join Master as m on m.code=c.code
my query :
return Json(context.CostCentre1.Where(x => x.Name.Contains(term)).Select(s => s.Name).ToArray(), JsonRequestBehavior.AllowGet);
Loading


Saber ShaikhRank #1,687 · 905 reputationPosted Dec 19, 2014, 2:09 AM EST
DataContext db = new DataContext();
dipti prasad76 reputationPosted Dec 19, 2014, 3:03 AM EST
This is my linq code but not working:
public JsonResult AutocompleteProfitCenter(string term)
{
Dal.WEBERPEntities context = new Dal.WEBERPEntities();
var result = (from c in ctx.CostCentre1
join m in ctx.Master1 on c.Code equals m.Code
where c.Name.Contains(term)
select new
{
Name = c.Name,
});
return Json(result, JsonRequestBehavior.AllowGet);
}
Ananth Padmanabham vemula98 reputationPosted Jan 2, 2015, 12:35 AM EST
Check two points in your code...
1.c.Code and m.Code are belongs to same datatype or not
2."term" has to be a string type
Munesh SharmaRank #174 · 13.9K reputationPosted Dec 19, 2014, 1:34 AM EST
from c in CostCentre1
join m in Master on c.code equals m.code into m_join
from m in m_join.DefaultIfEmpty()
select new {
c.code,
m.code,
c.otherthing
}