// Remove specified car.
ctx.Inventories.DeleteOnSubmit((from c in ctx.Inventories
where c.CarID == carToDelete
select c).First());
ctx.SubmitChanges();
}
At this point you can call each method from within Main() to verify the output:
static void Main(string[] args)
{
Console.WriteLine("***** CRUD with LINQ to SQL *****\n");
const string cnStr =
@"Data Source=(local)\SQLEXPRESS;Initial Catalog=AutoLot;" +
"Integrated Security=True";
AutoLotObjectsDataContext ctx = new AutoLotObjectsDataContext(cnStr);
InsertNewCars(ctx);
UpdateCar(ctx);
DeleteCar(ctx);
Console.ReadLine();
}
That wraps up our look at LINQ to SQL. Obviously, there is much more to the story than you
have seen here; however, hopefully at this point you feel you are better equipped to dive into further
details as you see fit.
Do'stlaringiz bilan baham: |