Solved

LINQ TO SQL add new records (C#)

Posted on 2009-04-01
2
537 Views
Last Modified: 2013-11-11
I have the following code to add new records to table, but the data is not saved in database. Any ideas what
could be the problem ? (list is not empty)
public bool PostInvoice(IList<tbAffiliatePostedReservation> reslist)
       {
           DBClasesDataContext dbcontext = new DBClasesDataContext();
           dbcontext.tbAffiliatePostedReservations.AttachAll(reslist);
           dbcontext.SubmitChanges();
           return true;
       }

Open in new window

0
Comment
Question by:crcsupport
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
cdaly33 earned 500 total points
ID: 24044633
If you're look to do an insert then I think you want InsertAllOnSubmit.
public bool PostInvoice(IList<tbAffiliatePostedReservation> reslist)
       {
           DBClasesDataContext dbcontext = new DBClasesDataContext();
           dbcontext.tbAffiliatePostedReservations.InsertAllOnSubmit(reslist);
           dbcontext.SubmitChanges();
           return true;
       }

Open in new window

0
 
LVL 1

Author Comment

by:crcsupport
ID: 24044755
it is as simple as that:) Thank you
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question