datacontext

Are Multiple DataContext classes ever appropriate?

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 ...

How to determine size in bytes of a result set from LINQ to SQL

When writing manual SQL its pretty easy to estimate the size and shape of data returned by a query. I'm increasingly finding it hard to do this with LINQ to SQL queries. Sometimes I find WAY more data than I was expecting - which can really slow down a remote client that is accessing a database directly. I'd like to be able to run a que...

How can I implement Caching Strategy in my Asp.net Mvc With linq2sql repository?

I dont know if I should use the httpcontext caching or the Enterprise Library Caching Application Block. Also, what is the best pattern for the caching Strategy when deleting or updating an entity that is part of a cached list? Should I remove all of a list from the cache or only remove the item from the cached list? If I update it will...

Does anybody familiar with big projects that was build with linqtoSql ORM ?

does it cost cost effective ? how can i profile the Sql calls to the server? ...

LINQ to SQL multiple DataContext-s

I'm trying to figure the best strategy about how to organize DataContexts. The typical DB we work has between 50 and 100 tables usually in third-normal form and with many relations between them. I think we have two options: Put all tables in a single context. This will ensure that anything we do will be committed in the correct order i...

LinkDataSource can't load DataContext

I am trying to populate a dropdown list control on an web page using VS 2008 and keep getting an error that it can't load the DataContext. My backend is a SQLx server 2005 DB. I create a Link To SQL data context and have 1 table in it. My LinKDataSource is as follows - asp:LinqDataSource ID="LinqDataSource1" runat="server"ContextTy...

Get object's DataContext

If I have the LINQ objects: public class SampleDataContext : DataContext { public Table<Customer> Customers { get { return this.GetTable<Customer>(); } } public SampleDataContext( string connectionString ) : base( connectionString ) { } } [Table( Name="dbo.tblCustomers" )] public class Customer { private Guid? customerID; ...

Can I specify a set of base parameters for a Linq-to-sql DataContext?

I have a LINQ-to-SQL DataContext that represents a parent-child relationship of Products to Prices. I'm iterating through a list of products and retrieving the prices for each one. The problem is that the tables behind both the Products and Prices contain a list of Products or Prices for multiple environments, determined by a 3 field co...

Silverlight DataBinding Error - Works in WPF Though!

Start a new Silverlight application... and in the code behind (in the "Loaded" event), put this code: // This will *NOT* cause an error. this.LayoutRoot.DataContext = new string[5]; But... // This *WILL* cause an error! this.LayoutRoot.DataContext = this; The error that is raised is "Value does not fall within the expected range." ...

Determine the source DataContext for a Linq to Sql query

In my application I have several DataContexts that connects to different databases with different schemas. In a custom user control I display the results of the query and let the user edit them, and when the user edits the data I want to persist the changes to the database. To do that I need a reference to the source DataContext (or at l...

MVC DataContext Ok to Share One Connection or Not

When is the "unit of work" no longer a "unit"? Which scenario is better on resources? THe first creates one connection wheras the second creates 4. using (DataContext dc=new DataContext) { var orders= from o in dc.orders select ( new Product { property a= from a in ..join... select x, ...

Customizing Linq to Sql DataContext

Is there anyway simple ways to add a property to Linq to Sql generated entity to reference its DataContext? For example: var myContext = new DataContext(); var product = context.Products.Where(p => p.Id == productId).SingleOrDefault(); and product entity has a property called "Context" (product.Context) that has a reference to the my...

What is wrong with putting Using Blocks in Repository?

I have using blocks in each method of my repository. If I want to cross reference methods, it seems it would be against best practices to initialize another Datacontext What am i doing wrong? If I declare a Datacontext in the class instead of using blocks in methods will I not lose power to dispose ?? public IList<something> GetSomethi...

"Property 'Path' does not have a value"

I'm using the following xaml to fill the dataContext: DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" The application works fine, but Cider complains that I must set the Path property. I'm interested in the entire object, and not a specific property though. I hope there's a way to get the designer support back...

Generic enforcement

I have a generic class public MyClass<TContext, T> where TContext : DataContext that effectively acts on an instance of another public class MyOtherClass<T> : IEnumerable<T> I want to enforce that the TContext has a Table<T>. Is there a clean way to enforce this? ...

Why is the Intellisense for properties and methods of instantiated datacontext not showing?

I have a web application project within VS 2008 and I have created a linq to sql file onto which I have dragged a table from my data base. The data context is created fine but when I instantiate an object of this type the only item I get showing on the intellisense for it is the class based on the table I dragged onto the designer and ev...

LINQ Resultset Issue

I built a site using LINQ and it has started to show issues with the results it brings up. The results brought out by the query do not reflect the data in the database, they reflect an older version of the database. In all the places where the LINQ data context was created it was disposed off properly. The sample code used in the sit...

LinqToSql declare and instantiate DataContext best practice?

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...

Should the LINQ context be closed every time?

Hello, In LINQ to SQL, is it necessary to close the context after performing a select on the database (and of course, after consuming the data)? if I leave it open, doesn't it mean that the connection to the server is left open? Thanks, Lucian ...

In a WebService with linq-To-sql can the datacontext be a static field?

I'm creating a webserivce that will be using Linq-To-Sql to perform select only queries. In this respect would having the DataContext as a static field / property by acceptable since the operations will never be ones that modify the database or track object changes? If not, what alternative approaches would be suitable? ...