0

My project consist of both public and private methods. I want to test the private methods. I have written test cases for public methods but I am unable to write the same for the private method. Please Help.

Piyush
  • 15
  • 4
  • You can pass list of data (primary key) to database side only once. in DB side, delete all records that match in the list of data. – Thit Lwin Oo Feb 13 '12 at 07:16

1 Answers1

0

you can read this blog, it is awesome. you need to create one exension method . blog explains you all stuffs. SQL UPDATES, Deletes

alteranativily you can try like this. // to make things happen. immeadiatly

 using (var dbContext= new yourDbContextClass())
    {
        context.ExecuteStoreCommand("DELETE FROM YOURTABLE WHERE PKID= {0}", Value);
    }
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83
  • I want to perform bulk delete, E.g if there are 10 records in an stud table with same college name then I want to use only linq query which can delete the 10 entries from stud table. I have written one query i.e var deleteclg =from remov in context.stud where remov.collegename=="ABC" select remov; context.stud.DeleteAllonSubmit(deleteclg); But the problem for deleting 10 records 10 delete queries are fired against the db. I just want to fire only one query. I have checked firing of Queries By SQL profiler Tool. – Piyush Feb 13 '12 at 10:04
  • it will work same only, if you use linq, then you need to implement extension methods as i gave the link above – Ravi Gadag Feb 13 '12 at 10:07
  • Did you understood my problem? see this e.g the same linq query in sql can be written as "Delete from stud where collegename="ABC" which directly deletes all the entries in single query but whenever i am using linq query 10 queries are fired I want such a LInq query which only fires one single delete query... – Piyush Feb 13 '12 at 10:11
  • u 'll not get like that query. its linq behaviour. it will do one by one update. . as i said you, u need to implement your own extension methods. and you can check the disscussion in this link http://stackoverflow.com/questions/869209/bulk-deleting-in-linq-to-entities – Ravi Gadag Feb 13 '12 at 10:15
  • Well that's fine but can we make changes into linq query to improve its behaviour. Also can you you provide me with the information on how to optimize the linq queries that are executed in Bulk. – Piyush Feb 13 '12 at 11:24
  • I want to optimize the queries that are executed no. of times in the loop. Also can we minimize the repetition of execution of linq queries. Also in the delete query of linq, the select query is fired so I just want to minimize the unnecessary execution of select query... – Piyush Feb 13 '12 at 11:30
  • you are not understanding what i told, any you either you need to implement your own extension method, or u need to use like this. this is the maximum possiblities. if you find alternative tell me. check that blog carefully you will understand what i mean. – Ravi Gadag Feb 13 '12 at 11:40