datacontext

Using LINQ GetChangeSet() to show user what happened

Say I have a L2S Update and I would like to display what changed to the user. Where does GetChangeSet() get populated? Immediately after I assign values or after context.SubmitChanges()? If the second; I could, theoretically, change the return type to IList and then return return context.GetChangeSet().Updates;? ...

Is there a cleaner way to Bind property to owner's DataContext?

I have some code that looks like this: <Expander Header="{Binding SelectedSlot.Name}" Visibility="{Binding ShowGroupSlot, Converter={StaticResource BooleanToVisibility}}"> <Controls:GroupPrototypeSlotControl Slot="{Binding DataContext.SelectedSlot, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x...

"Attach or Add an entity that is not new...loaded from another DataContext. This is not supported." Problem on insert of linker object.

Similar error as other questions, but not quite the same, I am not trying to attach anything. What I am trying to do is insert a new row into a linking table, specifically UserAccomplishment. Relations are set in LINQ to User and Accomplishment Tables. I have a generic insert function: Public Function insertRow(ByVal entity As Impleme...

Should Save/Update repository methods use a new data context?

Should each save/update method in a LINQ-to-SQL repository be wrapped in a new data context? Consider the SavePage method in my partial SqlPageRepository: public class SqlPageRepository : IPageRepository { private DB _db; public SqlPageRepository(DB db) // I use IoC { _db = db; } public IQueryable<Page> Ge...

WPF: How to bind and update display with DataContext

I'm trying to do the following thing: I have a TabControl with several tabs. Each TabControlItem.Content points to PersonDetails which is a UserControl Each BookDetails has a dependency property called IsEditMode I want a control outside of the TabControl , named ToggleEditButton, to be updated whenever the selected tab changes. I tho...

Whats the proper way to do explicit transactions with linq to sql?

I have some scenarios where I need to have multiple calls to .SubmitChanges() on a datacontext, but I want to explicitly control the transaction myself to make it atomic. For a while I have been doing this by creating a connection, creating a transaction on that connection, then creating the datacontext and passing it both. Lets assume f...

Where is the datacontext for the CustomerViewModel in the official MSDN MVVM article ?

Hello, I speak about josh smith article. can anyone show me please how the CustomerView.xaml specifically this:j <TextBox x:Name="firstNameTxt" Grid.Row="2" Grid.Column="2" Text="{Binding Path=FirstName, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" /> Why is ther...

Helping linqtosql datacontext use implicit conversion between varchar column in the database and table and a custom data type in my application

I am creating an mssql database table, "Orders", that will contain a varchar(50) field, "Value" containing a string that represents a slightly complex data type, "OrderValue". I am using a linqtosql datacontext class, which automatically types the "Value" column as a string. I gave the "OrderValue" class implicit conversion operators t...

Enabling Service Broker in SQL Server 2008

Hello, I am integrating SqlCacheDependency to use in my LinqToSQL datacontext. I am using an extension class for Linq querys found here - http://code.msdn.microsoft.com/linqtosqlcache I have wired up the code and when I open the page I get this exception - "The SQL Server Service Broker for the current database is not enabled, and a...

WPF/MVVM:Set multiple datacontext to ONE usercontrol

Hello, I have a UserControl with 5 small UserControl which are parts of the first UserControl. The first UserControl is datatemplated by a MainViewModel type. The other 5 small UserControls have also set the DataContext to this MainViewModel type. Now I want additionally that those 5 UserControls get a 2nd DataContext to access other...

WPF - Event procedure updates a ListBox DataContext?

This whole question is for WPF C#. I have a class that has an event procedure that can fire at any time. The event procedure contains some text data that I need to display in a listbox. What is the best practice for making sure that the DataContext of the listbox is updated accurately as the event procedure fires? ...

LinqToSql - Parallel - DataContext and Parallel

In .NET 4 and multicore environment, does the linq to sql datacontext object take advantage of the new parallels if we use DataLoadOptions.LoadWith? EDIT I know linq to sql does not parallelize ordinary queries. What I want to know is when we specify DataLoadOption.LoadWith, does it use parallelization to perform the match between each...

WPF : Multiple views, one DataContext

Hi, I'm working on a WPF application which must handle multiple screens (two at this this time). One view can be opened on several screens and user actions must be reflected consistently on all screens. To achieve this, for a given type of view, a single DataContext is instantiated. Then, when a view is displayed on a screen, the uniq...

Silverlight nested RadGridView SelectedItem DataContext

Hi, I'm developing a Silverlight 4 app and am using the 2010 Q1 release 1 RadGridView. I'm developing this app using the MVVM pattern and trying to keep my codebehind to a minimum. On my View I have a RadGridView and this binds to a property on my ViewModel. I am setting a property via the SelectedItem. I have a nested RadGridView a...

LINQ Data Context Not Showing Methods

For some reason my DataContext is not showing all the normal methods like SubmitChanges() etc in the intellisense. It also won't compile if I type in db.SubmitChanges(); Any idea what I'm doing wrong? Normally I don't have this issue, I have several other projects that work fine... Image of what I'm talking about: ...

Where should I set the DataContext - code behind or xaml?

(honestly I searched and read all the 'related questions' that seemed relevant - i do hope i didn't "miss" this question from elsewhere but here goes...) There are two different ways (at least) to set the DataContext. One can use XAML or one can use the code behind. What is the 'best practice' and why? I tend to favor setting it in X...

LINQ to SQL Foreign Key Constraint conflicts

I'm having a problem with LINQ. I have 2 tables (Parent-child relation) Table1: Events (EventID, Description) Table2: Groups (GroupID, EventID(FK), Description) Now i want to create an Event an and a child. Event e = new Event(); e.Description = "test"; Datacontext.Events.InsertOnSubmit(event) Group g = new Group(); g.Description =...

Use DataContext to create schema in an existing blank database file?

With a DataContext and a blank file-based database that already exists, is it possible to write the Data Context classes (i.e. the ones I added to the designer) to create the db schema? With a data context I only see the abilities to either: create a new database file and have its structure created at the same time, or to populate...

How to create databinding over two xaml files?

Hello, I am trying to come to a working understanding of how databinding works, but even after several tutorials I only have a basic understanding of how databinding works. Thus this question might seem fundamental to those more familiar with silverlight. Even if it is trivial, please point me to some tutorial that deals with this prob...

Populate datagrid using Datacontext in C# WPF

I'm trying to get data from file. The file first has three lines of text that describes the file, then there is a header for the data below. I've managed to extract that. What I'm having problems is getting the data below the header line. The data below the header line can look like "1 2 3 4 5 6 7 8 9 abc". DataGrid d...