ADO.NET :: Best Practices Of Using Data Context?
Feb 7, 2011
Here is the code of my Repository class:You see, I use singleton here. Also you see, there is a data context as class variable of Repository class.The main reason to use singleton here is a wish to avoid using 'using(NorthwindEntities context = new NorthwindEntities())' in every function.
[Code]....
This Repository is used in ASP.NET application. So only instance of NorthwindEntities (context) is used everywhere and that's why I never dispose it.So my question is: Won't this code cause connections to the DB that are not closed?
View 11 Replies
Similar Messages:
Nov 24, 2010
I have a web application where users can upload the photo. I do have a windows service running which takes the uploaded photo and crops it to different sizes. This runs in a specified interval. Photo will be visible to the user once after it's cropped. So once user uploads the photo and photo cropper has not yet run, they wont be able to see the photo. Due to this behaviour user thinks that there was some error uploading the photo and they will upload it again and again.
where the photocropper runs immediately when the user uploads the photos which is queued.
I am using asp.net & C#.
View 3 Replies
Apr 8, 2010
I have to pass information from a desktop application to Web application and vice versa. What are the best practices that are regularly used? Currrently I'm using Asp.Net and a Winforms. To pass data to Web Site im creating a (POST) WebRequest and posting an xml to the siteTo pass data to Application im using .Net Remoting from Asp.ne(I'm using Winforms is an adminstration and monitoring application.)
View 4 Replies
Apr 19, 2010
I am developing an ASP.Net 2.0 project that a call center will use for their scripting and data collection. Each screen will present the call center associate with a question and depending on their answer, will move on to the next screen. My question is what is the best practice for housing that data until the end of the scripting has been completed (i.e. in a Dataset or datatable), where should the storage container be declared and what's the best way to control the back button so it doesn't lose the data and try to repost?
View 8 Replies
Jun 29, 2010
I m developing new shopping cart by using mvc2.and i have followed sample video store application posted in asp.net.my question is: What is the best way to keep shopping cart data.is it in db or a session.
View 3 Replies
Dec 15, 2010
I've been out of the ASP.Net arena since 1.1, and I'm starting to get back into it after a hiatus.
In the past, I would generally create SqlDataReaders, wire them up to pull from tables in a database via direct sql or accessing database views (mostly in MSSQL), grab the data, and display it in some datatable, or datalist.
Modifying data would usually be calling a stored procedure in the database to add/modify data, and then retrieve it afterward.
Now that I read up, I see there are alot of new things in ADO.Net world; strongly typed datasets, auto-generated adapters, etc.
My question is, does anyone have a good reference on best practices (or a book recommendation) on how to handle data access, and data manipulation and display now? I'm assuming that there are more automatic ways to show and manipulate data than before, but the new details are quite vast (which is good), but slightly overwhelming for me.
View 1 Replies
Jan 24, 2010
I have written simple HttpModule. context.Response.Output.Write is working fine. but not context.Response.Write().
View 2 Replies
Jul 3, 2010
What is the common practice of input validation? In other words do you check for input validation on client-side, on server-side or on both sides?
Also, if performance is crucial to me, would just the client-side input validation be sufficient for my website without presenting any security risks?
View 6 Replies
Feb 11, 2011
I'm about to begin an ASP.NET MVC project and I'm not sure how to approach an aspect of the design. Basically, there is a user site and an admin site. In the admin sites, administartors design a form and send an e-mail link out to a handful of people. When the users click on the link, they are sent to the form.
Essentially what I'm wondering is what are the best practices when the model resembles looks more like a dictionary than a table?
In other words, instead of:
CREATE TABLE FormResponse (ResponseId, FormId, UserId, FirstName, LastName, BirthDay, Comments)
...containing 1 row per complete response
It's more like:
CREATE TABLE FormResponse (ResponseId, FormId, UserId, QuestionId, Value)
...containing 4 rows. 1 for the FirstName, 1 for the LastName, 1 for the BirthDay, and 1 for Comments.
View 2 Replies
Jan 29, 2010
I'm very new to MVC (just started 2 days ago), and I would like to know what the best practice is for outputing HTML.
I have a model named Tools.cs which contains the code below. It uses a stored procedure to return a recordset of menu items, and another to return a second level of menus for each first level menu. In another function, I then loop through the recordset and generate the HTML code to display the menu in a string, which is then returned.
I then have a controller MenuController.cs which calls the GetMenu method and puts the returned HTML string in the ViewData["RightMenu"].
I then have a view which displays the result.
My question is: would it be better practice to return my datareader to the controller into ViewData["RightMenu"], and then loop through it and construct my HTML in the View instead?How would I get that to work with that second level of menus?[Code]....
View 2 Replies
Feb 28, 2011
For WPF, there's the Microsoft Patterns & Practices's Prism project.
Prism provides guidance designed to you more easily design and build rich, flexible, and easy-to-maintain
Windows Presentation Foundation (WPF) desktop applications, Silverlight Rich Internet Applications (RIAs), and Windows Phone 7 applications I was wondering whether a similar project (reference implementation) intended for software developers building WCF applications exists.
In our main internal project (a .Net WinForms rich client app), we don't talk directly with the database but instead fetch and update data with ASP.Net web-services that we also control. Our current setup is giving us some bottlenecks. For a new smallish project, we want to try WCF. Objective question: Where do I find a not-too-basic WCF reference project?
View 2 Replies
May 7, 2010
In my experience building web applications, I've always used a n-tier approach. A DAL that gets data from the db and populates the objects, and BLL that gets objects from the DAL and performs any business logic required on them, and the website that gets it's display data from the BLL.I've recently started learning LINQ, and most of the examples show the queries occurring right from the Web Application code-behinds(it's possible that I've only seen overly simplified examples). In the n-tier architectures, this was always seen as a big no-no.I'm a bit unsure of how to architect a new Web Application.
View 2 Replies
Jul 18, 2010
All too often I find myself being required to design pages that flow through a series of steps. 1) Select from a set of options. Submit.2) Populate a page with results. Make changes. Submit.3) Do something based on the previous results. Submit.4) Confirm previous actions. Submit.5) Goto 1.An ecommerce site with shopping cart would be a textbook example of this.Now, there are any number of ways to deal with this. My question is, what is the recommended way to do it in asp.net? In PHP or ISAPI I would just use standard html controls, get the post data and do stuff with it, each on a different page
View 3 Replies
Jul 4, 2010
We are working on a project which has lots of routes that can be changed on-the-fly or new routes can be added dynamically. What are the best practices about managing lots of routes and adding routes on-the-fly without recompiling? Reading-Writing from-to database or from Xml Document in Application_Start?
View 4 Replies
Apr 2, 2011
Possible Duplicate: Best practices for exception management in JAVA or C# I am using class libraries and I try to put maximum code in class libraries so that it can be reused in other projects.Please advice me where I should put try catch blocks in class library functions or in front end forms (aspx pages) ?
View 3 Replies
Jan 25, 2010
I would like to know what are the best practices in using Javascript in ASP.NET in a pre-AJAX and pre-jQuery era. What I meant by pre-era is not the time before AJAX/jQuery was created, but rather the time before it is popularized and widely adopted (by a significantly large number of programmers).i.e. Is it good thing to store the script in a string variable and register it on demand (RegisterClientScriptBlock) or on startup (RegisterStartUpScript)?Although in using Javascript in ASP.NET, its usage in PHP and JSP are also welcome.
View 1 Replies
Aug 17, 2010
best practices to be followed in deployment of asp.net web application & WCF service in IIS 7 regarding the IIS 7 configuration settings , Security setting, application access level settings..
View 2 Replies
Jul 7, 2010
This question is for ASP.NET and SQL Server developers. What are your best practices with respect to setting up your development and test environment? I'm interesting in the following issues: How many tiers do you recommend and what goes on on each tier? Just dev, test, and production or perhaps dev, test, staging, and production? Which types of applications and/or servers should run on actual physical hardware and which can get away with a VM? What are your strategies for loosely coupling users from web sites, web developers from their web/app/DB servers, and DB developers from their DB servers?
How do developers stay "DRY?" What are the pros and cons to putting web, app, and DB servers on their own machines? Does putting servers on separate machines in order to minimize contention for a machine's resources trump any NIC and network latencies that might be introduced by putting them on different machines? How do you configure your web apps to minimize contention for resources (e.g. virtual directories, separate application pools, etc.) How and how often do you refresh your databases on each tier? Do you just refresh the data or both the data and objects?
View 1 Replies
Sep 30, 2010
We are in the midst of developing WEB application using .NET. so, i would like to know the Best practises for ASP.NET development, SQL server db, IIS security and network security as well. Where to get the information? I googled for it, but i cannot get the complete set and the info was updated 7 years ago. [URL]
View 2 Replies
Aug 29, 2010
I use VS 2010 (C#) with SQL server 2008. I prefer to use the entity framework.
I would like to know are there any good developer tools/ways to simplify work?
View 3 Replies
Sep 8, 2010
I have locked a set of administration pages on a website using the PrincipalPermission syntax ie:
<PrincipalPermission(SecurityAction.Demand, Role:=RoleBLL.ROLE_NAME_ADMINISTRATOR)>
View 3 Replies
Oct 8, 2010
Error3Type 'LinqChatDataContext' is not defined.
i have above error whne woring with linq
View 3 Replies
May 20, 2010
I have a member class that returned IQueryable from a data context
public static IQueryable<TB_Country> GetCountriesQ()
{
IQueryable<TB_Country> country;
Bn_Master_DataDataContext db = new Bn_Master_DataDataContext();
country = db.TB_Countries
.OrderBy(o => o.CountryName);
return country;
}
As you can see I don't delete the data context after usage. Because if I delete it, the code that call this method cannot use the IQueryable (perhaps because of deferred execution?). How to force immediate execution to this method? So I can dispose the data context..
View 2 Replies
Mar 31, 2011
I am creating a core library for one of our internal project. This core library supposed to contain some abstract classes and generic classes which will then be extended by specialized projects. For example, There is an AbstractPerson class with standard properties and methods for a Person class while another project will implement a Person class which will inherit from the AbstractPerson class to add project specific functionality.
Now we need to impelment DAL for this common and specialized projects.As most of operations are generic so i want to include them into core library as Repository classes. However, Repository classes need to access LINQ dataContext. Which is generated from the specialized databases. Hence there is no dataContext available in Core library to work. So how could i can create a common repository classes for generic methods which can reside in the common library.
View 1 Replies
Nov 5, 2010
I set the Databinding of a repeater to a list of classes i.e. List<Message>, I have used the ItemCommand event before to pull out individual ID's etc based on the CommandArgument, however is it possible to make the class itself the CommandArgument instead of one of its properties, this way I have them all at my disposal.For example say I have a list of messages and within the repeater I have this:
[Code]....
However I want to pass the Message class as the argument instead, can this be done?
View 5 Replies