c# - Remove ONLY the childrens with LINQ to SQL? -


i want delete childrens of item selected in datagridview linq sql , doesn't work. don't know if it's possible this. don't know how proceed, can please check @ code , tell me wrong? here's code :

private void cmdsupprimer_click(object sender, eventargs e) {     try     {         var catact = (from cata in tbcategories.categories                                cata.categorieid == (int)dgcategories.rows[0].cells[0].value                                       select cata).single();          (int = 0; < catact.jeuxes.count(); i++)         {             (int j = 0; j < catact.jeuxes[i].personnages.count(); j++)             {                 tbpersos.personnages.deleteonsubmit(catact.jeuxes[i].personnages[j]);             }             tbjeux.jeuxes.deleteonsubmit(catact.jeuxes[i]);         }         tbcategories.categories.deleteonsubmit(catact);          tbcategories.submitchanges();          dgcategories.datasource = null;         dgcategories.datasource = (from cats in tbcategories.categories                                    select new categoriedisplay()                                    {                                        categoryid = cats.categorieid,                                        categorynom = cats.categorienom                                    }).tolist();          messagebox.show("les enfants de cette catégorie ont été supprimés");     }     catch (exception ex)     {         messagebox.show(ex.tostring());     } }  

make datasource variable called data. can delete rows data , datagridview updated.

var data = (from cats in tbcategories.categories                                    select new categoriedisplay()                                    {                                        categoryid = cats.categorieid,                                        categorynom = cats.categorienom                                    }).tolist();  dgcategories.datasource = data; ​ 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -