asp.net mvc - records being deleted when creating and adding new record via Linq To SQL & MVC3 -



asp.net mvc - records being deleted when creating and adding new record via Linq To SQL & MVC3 -

i trying add together new comment comment table records in table beingness deleted exception of 1 added. example: allow have existing comment in database client 1. want add together new comment.

in controller have following:

list<customercomment> comments = _commentsrepository.customercomments.tolist(); customercomment newcomment = new customercomment() { custid = 1, revisionnumber = revnumber, comment = comment, client = _commentrespository.getcustbyid(1), commentdate = datetime.now, userid = 24, users = _commentsrepository.getuserbyid(24) }; comments.add(newcomment); _commentsrepository.savecomment();

in repository have following:

public int32 savecomment(customercomment comment) { seek { _db.submitchanges(); } grab { throw; } homecoming comment.commentid; }

while stepping through see no changes info until after create new comment , step savecomment method. unusual shows comments in table delete , new comment insert.

not understanding why thinks existing comments should deleted.

i have tried insertonsubmit samething took out.

one thing have noticed existing comment after loading in controller (comments) has client object null. when create new comment assigning client new comment (customer = _commentrespository.getcustbyid(1).) causing delete , why doesn't object created , assigned when loaded.

some additional info using pocos , xml mapping file.

maybe should not add together comment in memory storage seek adding new comment info context instead. presuming in repository have add together method... _commentsrepository.add(newcomment); shoukd work...

regardless of that, why storing whole client in database , matter user? should storing ids no? when need read onky info thrown out view may require additional info such client , user details, utilize dto object that. persistance in 1 thing, viewing info data perchance populated various tables thing...

asp.net-mvc linq-to-sql

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -