Sorry, but i think i was missing assembly
using System.Data.Entity;
Base.cs
using CRM.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
namespace CRM.Controllers
{
public class Base : Controller
{
private ScriptEntities db = new ScriptEntities();
public List<CustomerModel> getDetails()
{
var cust = (from c in db.Customers.Include(c => c.CUSTOMERTYPE)
join ch in db.CUSTOMERHEADs on c.Id equals ch.CustomerId into ps
from ch in ps.DefaultIfEmpty()
select new
{
id = c.Id,
name = c.Name,
company = c.Company,
mb1 = c.Mb1,
address = c.Address,
date_ = c.Date_,
origin = c.Origin,
type = c.CUSTOMERTYPE.Type_,
voucherno = ch.VoucherNo,
});
var details = new List<CustomerModel>();
foreach (var t in cust)
{
details.Add(new CustomerModel()
{
Id = t.id,
Name = t.name,
Company = t.company,
Mb1 = t.mb1,
Address = t.address,
Date_ = t.date_,
Origin = t.origin,
Type_ = t.type,
});
}
return details;
}
}
Now i can access my method in my controllers.
Controller Class:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using CRM.Models;
namespace CRM.Controllers
{
public class MasterController : Base
{
private ScriptEntities db = new ScriptEntities();
// GET: Customers
public ActionResult Index()
{
var details = getDetails();
var customers = db.Customers.Include(c => c.CUSTOMERTYPE);
return View(details);
}
}