datacontext

LINQPad, using multiple datacontexts

余生长醉 提交于 2019-11-28 04:05:00
I am often comparing data in tables in different databases. These databases do not have the same schema. In TSQL, I can reference them with the DB>user>table structure ( DB1.dbo.Stores , DB2.dbo.OtherPlaces ) to pull the data for comparison. I like the idea of LINQPad quite a bit, but I just can't seem to easily pull data from two different data contexts within the same set of statements. I've seen people suggest simply changing the connection string to pull the data from the other source into the current schema but, as I mentioned, this will not do. Did I just skip a page in the FAQ? This

Are Multiple DataContext classes ever appropriate?

筅森魡賤 提交于 2019-11-27 22:56:59
问题 In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary to create DataContext classes (which is usually done using the designer in VS 2008). From the UI perspective, the DataContext is a design of the sections of your database that you would like to expose to through LinqToSql and is integral in setting up the ORM features of LinqToSql. My question is: I am setting up a project that uses a large database where all tables are interconnected in some way through Foreign

Context Menu Binding to Parent Window's Datacontext

送分小仙女□ 提交于 2019-11-27 21:56:07
问题 I have a TreeListControl that binds to a collection in my VM. I also want to define the context menu inside the treelistcontrol having its header text bind to another string in my VM. how can I set the data context in this case? I tried to <Window.DataContext> <model:ViewModel></model:ViewModel> </Window.DataContext> <Grid> <Button Grid.Row="1" Command="{Binding CellCheckedCommand}"></Button> <TextBlock Text="{Binding HeaderText}" Grid.Row="2"> <TextBlock.ContextMenu> <ContextMenu> <MenuItem

Setting DataContext within UserControl is affecting bindings in parent

孤者浪人 提交于 2019-11-27 14:44:15
I have a basic UserControl that sets its DataContext to itself for ease of binding: <UserControl x:Class="MyControlLib.ChildControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" DataContext="{Binding RelativeSource={RelativeSource Self}}"> </UserControl> This is used in a parent XAML file like this: <UserControl x:Class="MyControlLib.ParentControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft

Ninject caching an injected DataContext? Lifecycle Management?

微笑、不失礼 提交于 2019-11-27 12:07:58
问题 I had a series of very bizarre errors being thrown in my repositories. Row not found or changed, 1 of 2 updates failed... Nothing made sense. It was as if my DataContext instance was being cached... Nothing made sense and I was considering a career move. I then noticed that the DataContext instance was passed in using dependency injection, using Ninject (this is the first time I have used DI...). I ripped out the Dependency Injection, and all went back to normal. Instantly. So dependency

Why are DataContext and ItemsSource not redundant?

非 Y 不嫁゛ 提交于 2019-11-27 10:17:50
问题 In WPF Databinding, I understand that you have DataContext which tells an element what data it is going to bind to and ItemsSource which "does the binding". But e.g. in this simple example it doesn't seem that ItemsSource is doing anything useful since, what else would you want the Element to do to the DataContext except bind to it ? <ListBox DataContext="{StaticResource customers}" ItemsSource="{Binding}"> And in more complex examples of ItemsSource , you have Path and Source which seems to

LinqToSql declare and instantiate DataContext best practice?

一笑奈何 提交于 2019-11-27 08:40:00
What's the best practice in terms of setting up my DataContext for easy access in my extended LinqToSql classes? For example, I have a "User" entity in my dbml and I want to add methods to that class like so: Partial Public Class User Public Function GetUser(ByVal UserID as Integer) as User 'Do Work End Function End Class In order to access my DataContext I'd have to declare it inside the method like so: Partial Public Class User Public Function GetUser(ByVal UserID as Integer) as User Dim dc as New MyDataContext() Return (From u in dc.Users Where u.ID = UserID).Single() End Function End Class

Entity Framework 4.1: how to work with per call life time data context?

谁都会走 提交于 2019-11-27 08:32:37
问题 According to this post, I am using a data context per call, so in each method of my WCF service, I use a using block to create a new data context. But I have some doubts in the form to work in this way. For example, I use a method getAllCLients() from my repository to get all the clients of the data base, then the service send to the client that call the method a list with all the clients. Then the user modify the information of some of them, three for example. The modify client perhaps I can

Silverlight - Setting DataContext in XAML rather than in constructor?

白昼怎懂夜的黑 提交于 2019-11-27 07:14:49
How can I set the DataContext on my Grid in XAML, instead of in the constructor? Here is how I do it in the constructor (LayoutRoot is the XAML Grid defined in the XAML): this.LayoutRoot.DataContext = this.HPVM; I would prefer to do it right in the XAML, but I do not know how to reference the HPVM object in XAML. HPVM is a public property on the USerControl class. It works fine as listed above, but again, I just want to know how to properties of the UserControl class in XAML, rather than always having to do it in code. Here is all the relevant code: <UserControl x:Class=

Should data contexts be static?

风流意气都作罢 提交于 2019-11-27 06:51:45
问题 I am using entity framework 4 and I create an datacontext for model in one of the base classes. But I was in profiling it and the context is being created every time I try to query, So I thought of making it static so that it is created only once and reused always. Do you think this is the best way to do it and data/object context should always be made static? Are there any disadvantages to making it static? Should data contexts be static or non-static? Any ideas or suggestions are welcome.