datacontext

C# add a Table<T> into an existing DataContext Instance

我的未来我决定 提交于 2019-12-23 14:58:09
问题 Is it possible that I can add Table<T> dynamiclly to an exisitng DataContext Insance in LinqToSQL? Here is my case: I have several classsed which are using [Test] attribute to declared as Table, I want to allow user to create the corresponding SQL Server tables during run-time. I understand that If I inherit the DataContext class, I can add member Table customers; in the class and it will automaticly create such a table at the backend database. However, the problem is that whether I can add

what's the benefits of using data context in xPages?

大憨熊 提交于 2019-12-23 12:06:40
问题 I have never used data context in xPages and would like to know the benefits, If I want to return something in memory I often call function in a SSJS scriptlibrary which I believe is also stored in memory. so let's say I have a function in ssjs that returns a notesdocument, this function might be called from several places in my xpage. will data context be benefitial in this case in regrards to having a function in a ssjs scriptlibrary. 回答1: dataContexts can be thought of as global variables.

Dependency Properties and Data Context in Silverlight 3

那年仲夏 提交于 2019-12-23 04:23:19
问题 I am working with Silverlight 3 beta, and am having an issue. I have a page that has a user control that I worte on it. The user control has a dependency property on it. If the user control does not define a data context (hence using the parent's data context), all works well. But if the user control has its own data context, the dependency property's OnPropertyChanged method never gets called. Here is a sample: My Main Page: <UserControl x:Class="TestDepProp.MainPage" xmlns="http://schemas

Which layer should create DataContext?

↘锁芯ラ 提交于 2019-12-23 03:22:13
问题 I have a problem to decide which layer in my system should create DataContext. I have read a book, saying that if do not pass the same DataContext object for all the database updates, it will sometimes get an exception thrown from the DataContext. That's why i initially create new instance of DataContext in business layer, and pass it into data access layer. So that the same datacontext is used for all the updates. But this lead to one design problem, if i wanna change my DAL to Non-LinqToSQL

Which layer should create DataContext?

旧街凉风 提交于 2019-12-23 03:21:02
问题 I have a problem to decide which layer in my system should create DataContext. I have read a book, saying that if do not pass the same DataContext object for all the database updates, it will sometimes get an exception thrown from the DataContext. That's why i initially create new instance of DataContext in business layer, and pass it into data access layer. So that the same datacontext is used for all the updates. But this lead to one design problem, if i wanna change my DAL to Non-LinqToSQL

DataContext not binding in Style.Trigger

血红的双手。 提交于 2019-12-22 18:09:37
问题 So I have some code similar to the following: (Forgive any typos-- I tried to simplify in the SO editor for the post) <my:CustomContentControl> <my:CustomContentControl.Style> <Style TargetType="{x:Type my:CustomContentControl}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=CurrentView}" Value="MyCustomView"> <Setter Property="Content"> <Setter.Value> <my:CustomView DataContext="{Binding DataContextForMyCustomView"/> </Setter.Value> </Setter> </DataTrigger> </Style.Triggers> </Style>

DataContext not set when using View as DataTemplate in ItemsControl

被刻印的时光 ゝ 提交于 2019-12-22 10:45:46
问题 I have an ObservableCollection of ViewModels that I'd like to bind to an ItemsControl containing the associated child Views. When I add ViewModels to my collection, an appropriate number of child Views are generated in the ItemsControl. However, the DataContext for each of the generated views is null. If I inline my child view, it works correctly. So, what do I need to do to set the DataContext for my child views to my ViewModels? Here's the relavent bits in my parent ViewModel: public

Linq to SQL DataContext: how to load data?

时光总嘲笑我的痴心妄想 提交于 2019-12-22 08:10:04
问题 (I'm completely new to Linq to SQL) I am creating a web app that works very closely with a database, I'm looking for the quickest and connection time efficient model and believing Linq to SQL to be this. I'm using C#/.Net4/Visual Studio 2010 For simplicity sake, I have a web .aspx page containing a number of asp Text Boxes. I want to give their Text values from SQL data via Linq to SQL object. I also have a file called DataClasses.dbml with a a table added in the design view. The code I have

How do you centralize the Entity Framework data context in a web application?

走远了吗. 提交于 2019-12-22 00:35:42
问题 In our application we use the repository pattern to retrieve and persist data from our data storage medium. The medium we opted to use is Entity Framework 4. This seems to be a very clean way to do things and has worked great 99% of the time. Now we are encountering an issue. We have two repositories, like this: public class UserRepository : IUserRepository { Entities dataContext = new Entities(); public User GetUser(string username) { return dataContext.Users.SingleOrDefault(x => x.Username

How to prevent Silverlight RIA Entity getting attached to datacontext before i'm ready

流过昼夜 提交于 2019-12-21 17:57:30
问题 I have a Silverlight 4 application for a simple 'TODO' list. The problem I'm having is that databinding is hooking up relationships on my TODO object, which causes the RIA data context to add it to the DataContext.TODOs list before I want it there. I want to treat the object as new and detached until I'm explicitly ready to add it to the datacontext. Here's how it works : I've got my TODO entity which is associated with a Status (RIA services entity relationship). I create a new TODO() entity