Click here to Skip to main content
15,897,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
public class wishlistController : ApiController
   {
       DataContext rdb;
       public wishlistController()
       {
           rdb = new DataContext();
           rdb.Configuration.ProxyCreationEnabled = false;
       }
       ~wishlistController()
       {
           rdb.Dispose();
       }


       public List<wishlist> Delete(int wishid = 0)
       {

           List<wishlist> deletwish = new List<wishlist>();
           deletwish =rdb.wishlists.Where(x => x.WishID == wishid).ToList();
           rdb.wishlists.DeleteOnSubmit(deletwish);// i am facing problem here.
           return deletwish;
       }

   }
Posted
Comments
Andy Lanng 12-Jun-15 4:13am    
so whats wrong with that? do you get an error?

We need more >_<
[no name] 12-Jun-15 6:06am    
thanks for reply.
jdeep84 12-Jun-15 5:31am    
It would be great if you post Error message with stack trace. this will definitely help you get quick response from experts out there.
[no name] 12-Jun-15 6:07am    
i have resolved this problem.
thanks

1 solution

XML
I have done it.

<pre lang="c#">
public class wishlistController : ApiController
    {
        DataContext rdb;
        public wishlistController()
        {
            rdb = new DataContext();
            rdb.Configuration.ProxyCreationEnabled = false;
        }
        ~wishlistController()
        {
            rdb.Dispose();
        }


        public List<wishlist> Delete(int wishid = 0)
        {

            //List<wishlist> deletwish = new List<wishlist>();
           var deletwish =rdb.wishlists.Single(x => x.WishID == wishid);
           rdb.wishlists.Remove(deletwish);
           rdb.SaveChanges();
           return rdb.wishlists.ToList();
        }

    }
</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900