473,800 Members | 2,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.A dd(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 8969
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************ **********@goog lemail.comwrote in message
news:xn******** *******@news.mi crosoft.com...
>
MyDataContext db = new MyDataContext() ;
db.ServiceLog.A dd(new ServiceLog() {...});
db.ServiceLog.I nsertOnSubmit(. ..) and db.SubmitChange s();

- Michael Starberg
Jun 27 '08 #4

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

Similar topics

0
1143
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 to DataGridView to SQL. Is is possible to generically map a XmlNodeType.Element Name to a dbml SQL table column?
0
2138
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 notepad text file; then one at a time I delete the changed tables from my DBML Diagram and drag a replacement from the Server Explorer Table list. Is there a better way to keep the Database Diagram and DBML Diagram in sync? I would rather not...
0
1635
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 x:Name="btnRegularDataContext" Margin="5"> <TextBlock Text="{Binding}" /> </Button>
2
2580
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 adivise? Thanks.
0
1394
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 created an app.config with connection string as <connectionStrings> <add name="LinQ2008.Properties.Settings.EmployeeConnectionString" connectionString="Data Source=Server1;Initial Catalog=Employee;User...
5
3830
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 another class somewhere making it access the dataContext methods?
0
953
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 don't think I know how to use the ISingleResult type since that is what it returns from what I can see. Any examples of how to do this? any examples I can find are either incomplete, or bad examples. The dataContext is called TestXmlDataContext, the...
1
4570
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 right way to use DataContext in this scenario? The service will obviously be used by multiple clients simultaneously. Should I be creating a "global" DataContext object that I use from within each of
2
9797
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 it seems that I need to set it to null first: Combo1.DataContext = null; Combo1.DataContext = dc;
0
1146
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 tables with exactly the same structure, say Day2, Day3 etc? I don't want to use synonyms, they are server wide. In multi-threading environment they might be not working. Thanks in advance,
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10274
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.