views:

47

answers:

1

I need to delete a record from the table

For one CategoryId I will have several serviceTypes..

Ex: CategoryId = 123 Service types related to this is 1 2 3 4 5

I need a query to delete servicetype 3 to CategoryId 123..

My method will be I will pass

Deleterecord(CategoryId,ServiceTypeId);
+3  A: 

If you're using LINQ to SQL:

var service = Services
    .Include("Category")
    .First(s => s.ServiceId = 3 && s.Category.CategoryId == 123);
context.Services.DeleteOnSubmit(service);
context.SubmitChanges();

If you're using Entity Framework:

var service = Services
    .Include("Category")
    .First(s => s.ServiceId = 3 && s.Category.CategoryId == 123);
context.Services.DeleteObject(service);
context.SaveChanges();
Richard Poole