datacontext

DataContext compiled query problem with .NET 4

核能气质少年 提交于 2019-12-08 19:48:01
问题 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[] args) +863348 System.Data.Linq.CompiledQuery.Invoke(TArg0 arg0, TArg1 arg1) +110 Every time when I run my query I am passing my context return StaticQueries

EntityFramework: Retrieve data with a condition on two different context

北城以北 提交于 2019-12-08 19:26:35
问题 I'm importing data between two different database(which have not the same context). So I've two different context. The goal is to import some data of the context A to the context B. Data in the context B are never directly edited, they are only imported from the context A. In the context B, I've in copy the ID from which it has been imported. Now I'm trying to retrieve a list all data which aren't in the context B or have a more recent version. I've a ModifiedAt" field in the two table,

wpf how to bind to DataContext existence?

别说谁变了你拦得住时间么 提交于 2019-12-08 15:53:33
问题 I set the datacontext dynamically in code. I would like a button on screen to be enabled/disabled depending if DataContext == null or not. I can do it in code when I assign the DataContext but it would be better if I can bind like that :) 回答1: You should be able to use a DataTrigger on the button style to disable your button when the DataContext is null. The other option is to bind the IsEnabled property to the DataContext and use a value converter to return false if DataContext is null and

Binding/DataContext Issue with ItemSource in WPF using MVVM

流过昼夜 提交于 2019-12-08 11:02:22
问题 I have a ViewModel that is a Window , inside this Window there are many UserControl s that I have made. These work fine and the bindings and DataContext s for each is set appropriately; all apart from one... In my MainWindowView XAML I have <Controls:LogViewerView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding LogViewerViewModel}"/> and in my MainWindowViewModel I have public LogViewerViewModel LogViewerViewModel { get; set; } The LogViewerView <UserControl x

LinqToSQL - mapping out the DataContext with lots of tables?

拈花ヽ惹草 提交于 2019-12-08 03:36:54
问题 I've been working on a project where I have been using LinqToSQL that involved a lot of tables. All of these where mapped in one .dbml file (i.e. only one DataContext ). I did this on the pretense that (currently) you cant join across multiple data contexts. For example... DB1DataContext db1 = new DB1DataContext(); DB2DataContext db2 = new DB2DataContext(); var query = from x in db1.SomeTable join y in db2.AnotherTable on x.Id equals y.Id select new { x.Column, y.Column }; Someone argued that

C# Linq to SQL connection string (newbie)

[亡魂溺海] 提交于 2019-12-07 23:56:07
问题 i am a new linq to sql learner and this is my very first attempt to create a data viewer program. The idea is simple, i'd like to create a software that is able to view content of a table in a database. That's it. I got an early problem here already and i have seen many tutes and articles online but I still cant fix the bug. Here is my code: static void Main(string[] args) { string cs = "Data Source=localhost;Initial Catalog=somedb;Integrated Security=SSPI;"; var db = new

How to programmatically set data binding using C# xaml

不打扰是莪最后的温柔 提交于 2019-12-07 18:43:53
问题 How do you programmatically set the DataContext and create a data binding in C# Xaml? Given a Class class Boat : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; internal void OnPropertyChanged(String info) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(info)); } } private int width; public int Width { get { return this.width; } set { this.width = value; OnPropertyChanged("Width"); }

How can I make UIElement support binding?

偶尔善良 提交于 2019-12-07 17:43:39
问题 DependencyProperties on UIElement s do not support databinding (you get something like: "Cannot find governing FrameworkElement..") . If you try, you get an error because WPF can not resolve the DataContext. From what I know, you get binding support if you inherit FrameworkElement or Freezable, but In this case I can not simply change the base class. Is there any way to get the UIElement to support data binding? I've tried to add the DataContext property to the UIElement class like this:

Prefetching data in with Linq-to-SQL, IOC and Repository pattern

大兔子大兔子 提交于 2019-12-07 15:28:31
问题 using Linq-to-SQL I'd like to prefetch some data. 1) the common solution is to deal with DataLoadOptions , but in my architecture it won't work because : the options have to be set before the first query I'm using IOC, so I don't directly instanciate the DataContext (I cannot execute code at instanciation) my DataContext is persistent for the duration of a web request 2) I have seen another possibility based on loading the data and its childs in a method, then returning only the data (so the

How do I use INotifyPropertyChanged in WinRT?

戏子无情 提交于 2019-12-06 15:34:24
问题 I'm a total newbie, just learning the basics of DataContext and the MVVM model. I've now got a grid bound to a view model object which implements INotifyPropertyChanged , however it appears that UpdateSourceTrigger (which all the WPF tutorials tell me to use) is not available for WinRT / Metro Style apps! How do I implement INotifyPropertyChanged then? I'm at the end of my tether here. I've spend nearly the whole day on the most basic of app examples, simply trying to get a grid to update