Linked Questions

0 votes
0 answers
83 views

I found the equivalent of the following in the software I work on: using(var dbContext = Startup.Services.BuildServiceProvider().GetService<ApplicationDbContext>()) { while(true) { ...
WillRoss1's user avatar
  • 123
15 votes
5 answers
11k views

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 ...
RichC's user avatar
  • 7,899
8 votes
3 answers
11k views

Traditionally, when we use SQL string to done some work, we have to close the sql connection before the page being closed, I was wondering if I use Linq to do the data operations do I still need to ...
user avatar
5 votes
4 answers
6k views

When showing my main window, I make a list of objects from linq-to-sql: using (var context = new Data.TVShowDataContext()) { Shows = new ObservableCollection<Data.Show>(context.Shows); ...
Vegar's user avatar
  • 12.9k
5 votes
4 answers
6k views

I have several classes based on System.Entity.Data.DbContext. They get used several times a request in disparate ends of the web application - is it expensive to instantiate them? I was caching a ...
sjmeverett's user avatar
  • 1,307
6 votes
3 answers
5k views

I belived it was not possible to get sql connection leaks when using LINQ, but perfmon tracing of NumberOfReclaimedConnections shows a high number and on high load we sometimes get exceptions like "...
Atle's user avatar
  • 571
5 votes
3 answers
6k views

I've been getting lots of connection pool timeouts in my ASP.NET MVC project. I've been reading that even though Linq-to-SQL should be disposing for me it doesn't always work and also that not ...
Darcy's user avatar
  • 5,368
2 votes
3 answers
2k views

I am making sure to fully understand this following code: static void Main(string[] args) { var person = new Person {FirstName = "Nadege", LastName = "Deroussen", BirthDate = DateTime.Now}; ...
dtjmsy's user avatar
  • 2,770
5 votes
3 answers
2k views

I encapsulate my linq to sql calls in a repository class which is instantiated in the constructor of my overloaded controller. The constructor of my repository class creates the data context so that ...
Chris Simpson's user avatar
3 votes
1 answer
4k views

In Our project I have used LINQ to SQL for every kind of database interaction. Now from what I know , When I create and use DataContext object : it opens the connection , crates a transaction , ...
Zeus's user avatar
  • 3,397
1 vote
2 answers
2k views

I am using "Single data context per atomic operation" approach while using Linq to Sql in an ASP.NET MVC application. So far, I have been using a singleton datacontext, which I learnt has many issues,...
Marek's user avatar
  • 10.4k
3 votes
2 answers
3k views

UPDATE As Mathias notes below, this exact problem has been reported and resolved here: ASP.NET-MVC (IIS6) Error on high traffic: Specified cast is not valid ORIGINAL POST This may be too specific a ...
Mike's user avatar
  • 7,701
1 vote
3 answers
1k views

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 ...
jamone's user avatar
  • 17.4k
2 votes
2 answers
669 views

I'm having some problems with DataContexts using linq to sql for an asp.net c# web application. I first had problems with exceptions being thrown as I didn't dispose of the DataContext, same errors as ...
annelie's user avatar
  • 2,649
0 votes
2 answers
2k views

There are two tables: Account (id) and BranchId(Id,Name,AccountId) and I have this code in pageload protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (...
Jags's user avatar
  • 1,466

15 30 50 per page