In my Relation i have two tables relation (one to many)
table country
Id (primary key)
Countryname
table City
Id (primary key)
Cityname
Countryid (forign key)
I have controller City have the following function
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LinqProject.Models;
namespace LinqProject.Controllers
{
public class CityController : Controller
{
mytaskdbEntities db = new mytaskdbEntities();
// GET: City
public ActionResult List()
{
return View(db.Cities.ToList());
}
and in view of List as following
| @item.Cityname | @item.Country.Countryname |
What i need actually adding delete button to view of list of city
and i can delete city when click button delete
how to do deleting record by linq
the final result as following
USA NEWYORK DELETEBUTTON
USA WASHINTON DELETEBUTTON
FRANCE PARIS DELETEBUTTON
when click delete button for row USA NEWYORK it will delete
and remaining two record
USA WASHINTON DELETEBUTTON
FRANCE PARIS DELETEBUTTON

ahmed salahRank #2,612 · 534 reputationPosted Aug 14, 2016, 2:26 PM EDT
Ankur Goel75 reputationPosted Aug 16, 2016, 9:46 PM EDT