I just started using LINQ a couple of days ago and i'm stuck now.
Given a certain type i need to recurse to the top. For example:
hierarchy: Client, Project, Department.
proposed function descriptor to load hierarchy:
public static IEnumerable<object> LoadPath<T>(int id) where T : class, ContentItem, new()
{
}
the user specifi...
Take the following example:
MyDataContext context = new MyDataContext(); // DB connection established.
MyTableRecord myEntity = myDataContext.Table.FindEntity(12345); // retrieve entity
Say my entity has relationships with other tables which I would access via
foreach (var record in MyEntity.RelatedTable)
Do I need to keep my DataC...
I have studied a bit into the lifespan of the DataContext trying to work out what is the best possible way of doing things.
Given I want to re-use my DAL in a web application I decided to go with the DataContext Per Business Object Request approach.
My idea was to extend my L2S entities from the dbml file to retrieve information the da...
Hi,
I am looking for architecture like as follows:
Database --> DataSet --> DataContext(Linq)/ ORM Entity --> GUI Application
I want to fetch data from database and keep into DataSet so if database id disconnect my
application doesn't affect.
But DataSet is not supporting Object-Relational-Mapping (ORM) Model. I am interested in
...
DataContext/Entity Model always read data from Database. is there any way DataContext/Entity Model will read the data from DataSet.
Thanks
...
Hi.
I am binding WPF with Entity-Framework.
The Window.DataContext property is set to a Quote.
This Quote has a property Job, that I have to trigger Quote.JobReference.Load it should load from the server.
<ContentControl Content="{Binding Job}"
ContentTemplate="{StaticResource JobTemplateSummary}"/>
As you can see above, I am t...
I have a LINQ datacontext and a ObservableCollection holding records for a Companys table in SQL
Changes to the current records and new records made to the current datacontext (DataDC) are reflected when I do a
DataDC.SubmitChanges();
However if I have another Window with a separate DataContext to the same tables, if I modify fields...
For example, I have 2 methods that use one DataContext (Linq to sql).
using(DataContext data = new DataContext){
// doing something
another_datamethod(data);
}
void another_datamethod(DataContext data){
// doing
}
Use this style? Or with the same result, I can create separate "using DataContext". What benefits, I would a...
Is this possible to populate some constant small tables as cache for DataContext without using database?
For example, I have 10 Roles rows, and wonna quick (without database hit) access to them when doing big select?
...
Suppose you have a single web portal application that is used by a number of different clients. For reasons of security and portability, each client's data must reside in a separate database. The schema for each of these databases is absolutely identical.
How does one go about accessing these separate databases from a single SQL Serve...
The buzword in Linq now days is "unit of work".
as in "Only keep your datacontext in existence for one unit of work" then destroy it.
Well I have a few questions about that.
I am creating a fat client WPF
application. So my data context needs to track the entire web of instantiated object available for the user on the current screen. ...
I'm using a viewmodel pattern, so my DataContext for my custom user control is actually a viewmodel wrapper for the real data.
My custom control can contain hierarchal instances of the custom control.
I set up a DependencyProperty in the custom control for the real piece of data, with the hopes of creating a new viewmodel for that data...
I use LINQ to SQL in a WPF project. I have made small changes in the database (changed datatype of the fields, which contain no data).
Now I want to regenerate (refresh) the LINQ to SQL DataContext of this project (I use VS 2008). I try to right-click on .dbml item in my Solution Explorer and choose "Refresh", but nothing happens.
How ...
Hi,
When you create a datacontext, its connection is closed until you retrieve objects and it stays open when you retrieve objects in case you use deferred operators or late binding.
Is it possible (in an extension method of the datacontext of not) to force the datacontext to open its Connection without querying LINQ with LINQ or doing...
I have a wpf app with the datacontext set to an instance of a viewmodel class. It all works fine except where I need to access a property of the viewmodel in a listbox with the datacontext set to a collection that is contained in the ViewModel class. On msdn it says you can escape using the \ character but that has not worked for me
My ...
I have a program in which I am performing non-atomic updates to the database with a single DataContext (that is, the changes are submitted when the user clicks Save, not after each transaction).
When the user saves, I would like to be able to query the database (as it would be when I call submitChanges()) and do some checks just before ...
I would like to discard all changes made to linq tables (this means -- I use linq, and data are changed on client side, the data on server are intact). How to do this?
EDIT: problem partially solved
http://graemehill.ca/discard-changes-in-linq-to-sql-datacontext/
It works as long as you don't use transaction. When you do and you use m...
I'm working on a ASP.Net webform app and I am wondering how long I should keep my data context around. Currently I create a context on each page load, and that context is used in every db access for the entire page load. Should I be using a context only in each method that needs it, and dispose at the end of the method? I understand that...
I need to find out if an object with a particular primary key is already attached to a DataContext and get the entity from the DataContext if it is attached. Is there any way at all to do this that doesn't require Reflection with full trust?
Ideally, I would like to call GetCachedObject(), but I'd have to use reflection to get at that,...
The following code is causing a "This query contains references to items defined on a different data context" error. My 2 data contexts are created with 2 nested using blocks around the code that calls this method and displays its results on screen. The methods that this method calls only use the data context passed in to them, they don'...