Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

LINQ TO SQL add new records (C#)

Posted on 2009-04-01
2
Medium Priority
?
556 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
2 Comments
 
LVL 9

Accepted Solution

by:
cdaly33 earned 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

886 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