jeudi 13 août 2015

[ ASP.Net ][ MVC ] Linq to SQL " 2 Query "

this is my database : http://ift.tt/1TA1c65

this is my coding

public ActionResult Index()
    {
        IList<TicketListModel> TicketList = new List<TicketListModel>();
        var TicketListQuery = from Tickets in db.Tickets
                              select new TicketListModel
                              {
                                  Number = Tickets.Number,
                                  RequestDate = Tickets.RequestDate,
                                  Applicant = (from Applicants in db.Employees where Applicants.ID = Tickets.ID select new { Applicants.Name }).First(),
                                  ComName = ComLibs.Name,
                                  ProbType = Tickets.ProbType,
                                  ProbDetail = Tickets.ProbDetail,
                                  Status = Tickets.Status
                              };
        TicketList = TicketListQuery.ToList();
        return View(TicketList);
    }

I'm want to show "Applicant name" but in table "Ticket" the Applicant is a "int" so just select Applicant name in table Employee where Applicant ID equals Employee ID then select a Employee name

plz help me thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire