473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DBML - DataContext - How to insert?

Hi there,

I have added a database model to my application and dragged a couple of
tables on it. Then I wrote a couple of selects using LINQ to SQL and
everything works fine.

But I can't fingure out how to add new items. For example, I have a
table named ServiceLog. I thought I could just go like:

MyDataContext db = new MyDataContext();
db.ServiceLog.Add(new ServiceLog() {...});

But there is no such Add method. Either I've got complete wrong
expectations about how entities for the model are generated, or I made
a mistake. Can anyone help? Thanks in advance.

Matthias
--

Jun 27 '08 #1
3 8958
look for InsertOnSubmit; it is perhaps ironic that there used to be an
Add etc, but is was renamed because it was causing confusion (i.e.
peopele were confused when it didn't get added until SubmitChanges was
called).

Marc\
Jun 27 '08 #2
Hey Marc,

thanks a lot for your reply. Works perfectly. I was just looking in the
forest for trees :)

Kind Regards. Matthias
--

Marc Gravell wrote:
look for InsertOnSubmit; it is perhaps ironic that there used to be
an Add etc, but is was renamed because it was causing confusion (i.e.
peopele were confused when it didn't get added until SubmitChanges
was called).

Marc\
Jun 27 '08 #3

"Matthias S." <ma**********************@googlemail.comwrote in message
news:xn***************@news.microsoft.com...
>
MyDataContext db = new MyDataContext();
db.ServiceLog.Add(new ServiceLog() {...});
db.ServiceLog.InsertOnSubmit(...) and db.SubmitChanges();

- Michael Starberg
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: camarkco | last post by:
Hi, What is the best way to get an array of the columns of a SQL table encoded in a dbml file in OrcasBeta2? My project is reading XML into SQL tables, I want to go directy XML to SQL, not XML...
0
by: viepia | last post by:
Hi, My project writes records to a new SQL Server 2005 database with currently 18 tables. When I change the Database Diagram for my database I save the copy the list of changed tables to a...
0
by: =?Utf-8?B?V29ua28gdGhlIFNhbmU=?= | last post by:
Hi All, Perhaps its because its been a long week, but I just can't seem to figure out how to bind data in a DataTemplate using DataContext. The following is in the XAML code: <Button...
2
by: | last post by:
In the operation,it is neccessary to create a new table by smo and then insert some data into the new table by DataContext.Executecommand(). Is it possible to implement in a transaction? If no,any...
0
by: silpa | last post by:
Hi, I am doing a sample VS 2008 project. I have added a dbml file.On the designer,I have dragged a table "emp" from a database "Employee" which is in my server(for example Server1). It...
5
by: Andy B | last post by:
I was just wondering, when you create dataContext methods, should you put business logic there to try and minimize pushing data through 2-3 layers of code? or should the business logic still go in...
0
by: Andy B | last post by:
I have a stored proc that selects all from a database table. I drug it from the server explorer onto the o/r designer to make it part of the dataContext. Now I can't figure out how to use it. I...
1
by: Ragesh Krishna | last post by:
Hello, I'm creating a WCF service in which I use LINQ to SQL to do all my data access. I have a couple of architectural questions about using LINQ to SQL from WCF services: 1) What is the...
2
by: =?Utf-8?B?V29ua28gdGhlIFNhbmU=?= | last post by:
Hello, I have a ComboBox that has a DataContext set on it. When a PropertyChanged event is fired (based on a static instance of some class), I'd like to update the DataContext on the combo, but...
0
by: Vladimir Iahnenco | last post by:
Hi, I created dbml LINQ to SQL file and dragged a table into it. It created an object, say Day1, to read data from table Day1. Is it possible to use this object from DataContext reading other...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.