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

Ananth Padmanabham vemulaPosted Jan 2, 2015, 5:35 AM
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
dipti prasadPosted Dec 19, 2014, 8:03 AM
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);
}
Saber ShaikhPosted Dec 19, 2014, 7:09 AM
DataContext db = new DataContext();
Munesh SharmaPosted Dec 19, 2014, 6:34 AM
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
}