Simple case:
<usercontrol>
<Views:UserListView x:Name="settingsTreeView"/>
<Button DataContext="{Binding ElementName=settingsTreeView, Path=SelectedItem}"
Command="{Binding CreateChildCommand}"/>
</usercontrol>
The task just is to bind to button a DataContext which implements CreateChildCommand.
DataContext is the sel...
I have an .mdf file which I'm trying to add a record to, using linq in C#.
My code is:
dbDataContext context = new dbDataContext();
book b = new book();
b.title = "Test Book";
b.isbn = "123789";
context.books.InsertOnSubmit(b);
context.SubmitChanges();
When this code runs, the record is not inserted, and I get no error messages. If I ...
I have a scenario where I need to open multiple datacontexts which point to different databases. I am only writing to one of the databases though and reading from the others ... so technically the transaction should only be against one of the databases.
I'd like to avoid having the TransactionScope upgrade into a distributed transaction...
I noticed when performing many database transactions using BeginSaveChanges(null, null) the last query is sometimes unsuccessful. Is it because the instance of my DataContext died too quickly for the query to be performed?
When I changed my code to use the normal SaveChanges all the queries are successful.
Specifically, I'm performing ...
I have created a method in my data context that is mapped to a SQL stored procedure. The method is used in an ASP.NET application, and it is called twice in the lifecycle of a page. It returns the same single object in both cases (i.e. same primary key).
After the 1st call some data changes are made, so on the 2nd call the stored proce...
I know this looks a bit long but i tried to explain the problem as throughly as i could.
We are having a very 'exotic' problem with the linq to sql data context class. We have a n-tiered architectured structured like this: We have 3 classes MotherClass, ChildClass, ChildChildrenClass
MotherClass looks something like this:
public class...
I have a Page page in a Frame frame, with frame.DataContext = "foo".
(page.Parent as Frame).DataContext is "foo". ok
BindingExpression for page.DataContext is null (also forced with ClearValue). ok
page.DataContext is null. but I expected "foo"!
Why isn't the DataContext inherited? As far as I understand the Frame sandboxes the conte...
Hello,
I have 3 Buttons add,delete,open as RelayCommands in my DocumentViewModel.
Below you see how I have bound them. Of course those binding does not work, because the data is set to the ItemsSource of the ListBox and the buttons are outside of that...
What I tried then is to set the DataContext at the first StackPanel you see in my ...
I have a usercontrol which I need to set a specific DataContext on. The usercontrol uses multivalueconverters. However, the binding in multivalueconverter fails to use the datacontext. It works fine for regular value converters. Anyone know what is going on? To clarify, below code is not similar to my real code, it's just a sample repro...
The MSDN page for the DataContext class says:
Represents the main entry point for the LINQ to SQL framework.
Yet it looks like the constructors will take any ADO.NET IDBConnection. Am I right in thinking that a DataContext can wrap any ADO.NET connection? Or are there special things that need to be considered when using a connecti...
hi, I'm getting this error when the program executes mainDb.SubmitChanges():
INSERT INTO projects
VALUES (@p0)
SELECT CONVERT(Int, SCOPE_IDENTITY()) AS [value]
-- @p0: Input String (Size = 0; Prec = 0; Scale = 0) [test2]
-- Context: SqlProvider(Sql2008) Model: AttributeMetaModel Build: 3.5.30729.4926
my code has the following files:
P...
I've been using databinding in several simple situations with pretty good success. Usually I just use INotifyPropertyChanged to enable my codebehind to modify the GUI values on screen, rather than implement dependency properties for everything.
I am playing with an LED control to learn more about databinding in user controls, and was f...
I am implementing the IRepository interface against an Oracle database.
public interface IDinnerRepository {
IQueryable<Dinner> FindAllDinners();
IQueryable<Dinner> FindByLocation(float latitude, float longitude);
IQueryable<Dinner> FindUpcomingDinners();
Dinner GetDinner(int id);
void Add(Dinner dinner...
I have a UserControl which contains 4 ToggleButtons and I'd like to trigger a custom event that an interested object can listen for which provides a status, based on the ToggleButton Checked values and also value(s) from the DataContext object.
Getting the ToggleButton checked values and deriving a status is simple enough, however I can...
I have a TabControl binding to some items. Underneath it is a Button where I can add items dynamically. On adding an item, the new item should become the active Tab (works fine with TabControl.SelectedItem):
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xml...
Here's the scenario:
I have an ASP.NET user control that runs a LINQ query, stores the results in a generic List, then dynamically loads another user control (into a Placeholder) and passes one of the objects from the List to the control through a property on the control.
The child control displays data from the object and allows the u...
My project (UI layer is asp.mvc) was developed using .NET 3.5. After upgrading to .NET 4.0 I have got problem with compiled queries:
[ArgumentException: Query was compiled for a different mapping source than the one associated with the specified DataContext.]
System.Data.Linq.CompiledQuery.ExecuteQuery(DataContext context, Object[] ...
Here's the basic setup. On an ASP.Net website, there are a few pages that display reports from data that comes from a database. All the data comes via stored procedures that is accessed usign Linq to Sql. These pages may have some very high traffic at different times. We're using ASP.Net with the MVP pattern, and Unity for IoC (although ...
Is it possible to use the DataContext class to connect to an Oracle DB?
I am reading some examples on MSDN
I need an example where the context is used to connect to Oracle.
...
I have a class that uses linq to access the database. Some methods call others. For example:
class UserManager
{
public User[] getList()
{
using(var db = new MyContext())
{
return db.Users.Where(item => item.Active == false);
}
}
public User[] addUser(string name)
{
using(var db...