Where can I get custom libraries for ASP .Net? Specifically I am looking for ready made database access library that allow me to select, insert and update a database using transactions. I know how to do create but I am trying to use an existent library that does all that and handles exceptions and errors so exempt from the hustle of creating that from scratch and go into errors.
You can use Microsoft's free Enterprise Library for DataAccess, Logging, Caching, Security and Configuration. It's very commonly used.
Also you can use code generators like free .NET Tiers, but you will need CodeSmith if you want to use it.
I'd suggest looking at either using LINQtoSQL and the DBML designer to map your database tables onto objects in your system or a more full-featured ORM, like nHibernate.
You may want to look at something called Speedy.net. I have never used it, but it looks interesting. I have used other code that these people have written, and normally it's pretty good. For the small amount of money that it costs it might be worth trying out.
Related
We are going to develop many small applications using asp.net (c#) with oracle database. I would like to write a simple class library say dataaccess.dll that has most of the functionality for connecting to database, executing a sql query, update or insert or delete etc so that i could reuse them in my many small projects. Is there a good example online somewhere that i can get started from?
Well, probably i didnt explain my question properly..
I am not looking for how to make asp.net connect to oracle or how to execute a query (throught odp.net) from asp.net .
I am looking for ways to construct a class library with methods such as connect(),executeQuery(),insert(),update(),delete() methods which would accept connectionstring,sql query text etc as parameters from any c# program. What i want is a generalized dataaccess code or guideline to develop one based on odp.net that i can reuse again and again.
Thanks.
Search around for ODP.net which is what you'll be using. This is a helpful search term, but you'll find a lot of examples for your specific needs.
Look for pages that explain how to set up your classes to use the connector such as http://ergemp.blogspot.com/2008/10/querying-oracle-with-c-and-odpnet.html
Make sure to pay attention to the type of objects you're using to select data and don't confuse SqlDataSource with OracleConnection.
Look for pages detailing the use of the Oracle client, Oracle.DataAccess.Client.
You may know most of this, but in case someone find this question and doesn't, they get some info.
I have ASP.NET project and I want to know what is better to use.
ODBC connection and with Server Explorer (drag and drop make DataSet and modify it) or do some DBconnect class with connection to database, queries and use it for GridView?
When I use server explorer, I don't have good feeling because all logic is on aspx page and I do not separate from the application layer logic layer.
It will be a lagre application, databese(PostreSQL) have 18 tables and difficult constraints and application have to generate some documents etc. .
"Better" depends entirely on your situation. Is the purpose to get something done as quickly as possible for internal users at your company, or is this going to be a commercial site that will need to be highly extensible and needs to be as easy as possible to maintain? Will you need to integrate with other platforms possibly built using other languages at some point? The answers to all of these questions should affect your decision.
If you're looking to separate your project into distinct layers, then I would recommend an ORM such as NHibernate or Entity Framework (there are other commercially available ORM products out there, but these are the ones I'm familiar with and which you can easily get help with on this site).
Create a DataSource with LINQ to Entity. It let you the liberty of LINQ with the peace of mind of when you change something il will break your build so you will be able to debug more efficiently.
Well if you have total flexibility, I would recommend using C# ASP.NET 4 with MVC3 razor for the UI and application code. Use Entity Framework 4.1 code first for the data access layer.
This way you will always work with real objects that you create, and with List<realtype> instead of the total mess that exists with datasets.
I want to use NHibernate with Asp.net 3.5 but i don't know how to use it.I search on
Google but couldn't find the complete explanation about why to use NHibernate,Advantages of using it and integration with Asp.net projects.
I would suggest checking out Castle and NHibernate. I recently started using it and was blown away with what it can do. Castle manages all your sessions for you. Also it is easy to use LINQ with it.
Check out
http://davidhayden.com/blog/dave/archive/2008/04/28/NHibernateCastleActiveRecordTutorialUninitiated.aspx
Another great tool to use (Should work with ASP.Net) is the Nhibernate Profiler
http://nhprof.com/ It shows you what queries are being generated and the time its taking to run.
Also if you already have your database created you can download this tool http://www.agilityfororms.com/Home/Products/AfoCastleActiveRecordModelCodeGenerator/ It will create your models based on your database. Its works great for the most part. Although you have to register to download the free version still worth checking out.
Fluent NHibernate is supposed to be good as well although I have no experience with it. Might be worth checking out. http://fluentnhibernate.org/
You could have a look at this :
http://www.codegod.de/WebAppCodeGod/nhibernate-tutorial-1---and-aspnet-AID25.aspx
And this :
http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx
I'm nearing completion of my first project with it, and I've had mixed results. For basic data persistence, and assuming you already knew how to use it, it's much faster to build an application with it. You don't really have to worry about building stored procs and differentiating between new objects and updated objects.
On the other hand, until you're quite comfortable with it, it can take a long time to do something that would have been simple before. I've had a couple of problems, and it has been difficult and time consuming finding solutions to them.
To be fair, I've only written small applications with it and it has made the development process more difficult than I would consider required. The pain of using it is fairly similar from one app to the next, the benefits scale...
The best place to look is at NHibernate Forge. There's Blogs, wikis and groups that will help you out.
As for advantages of using it that is something you need to workout for yourself. Is it more advantageous than LinqToSql or Entity Framework? It depends on the project size and what you are actually looking for.
I am developing a applicatin which are having more than 5000 users once upon time. I using
ASP.NET 3.5 framework for developement. I want to develope a high performance DAL Layer
using latest technolgies like linq,ADO.NET Entity,ADO.NET Data services. I also want to make sure that it shuld be generic to all the future developement. Can any one pleasae Let me know which pattern i should use to develope that Database Access Layer. I am also
want to use microsoft enterprise library for that.
I think you should look at NHibernate and Fluent NHibernate.
You could save yourself a lot of time by not writing your own DAL. Only you know your non-functional requirements around perf and whether you're optimizing for reads, updates or something else, so write some tests, prototype, and see how it goes.
My personaly opinion is that Microsoft Ent Lib and perf aren't best buddies, but again you should prototype and prove this early in your dev cycle.
You can use Linq to SQL.
You can also take a look at this article series for creating an actual DAL using the same technology.
I am in the early stages of planning a conversion of a large classic ASP database application to ASP.Net and I'm having trouble picking out which data access method to use. I have played around with Linq To SQL, Dynamic Data, strongly typed datasets, Enterprise Library (Data Access Application Blocks), and a tiny bit with Entity Framework, but none of them have jumped out to me as "the one". There are just too many choices - my head is swimming, help me choose!
Perhaps it would help to give some background on the application that I am converting along with the priorities...
The back end is Microsoft SQL Server (2005 or later) and we are committed to that, so I don't need to worry about ever supporting a different database platform.
The database is very mature and contains a great deal of the business logic. It is highly normalized and makes extensive use of stored procedures, triggers, and views. I would rather not reinvent two wheels at the same time, so I'd like to make as few changes to the database as possible. So, I need to choose a data access method that is flexible enough to let me work around any quirks in the database.
The application has many data entry forms and extensive searching and reporting capabilities (reports are another beast which I will tackle later).
The application needs to be flexible enough to deal with minor changes to the database structure. The application (and database) may be installed at different sites where minor custom modifications are made to the database. Ideally the application could identify the database extensions and react appropriately. In other words, if I need to store an O/R mapping in the application, I need to be able to swap that out (or refresh it easily) when installing the application and database at a new site.
Rapid application development is critical. Since the database is already done and the user interface is going to closely match the existing application, I'm hoping to find something where we can crank this out fairly quickly. I am willing to sacrifice not using the absolute latest and greatest technology if it will save time in development. In other words, if there is a steep learning curve to using something like Entity Framework, I'm fine with going something like strongly typed Datasets and a custom DAL if it will speed up the process.
I am a total newbie to ASP.Net but am intimately familiar with Classic ASP, T-SQL and the old ADO (e.g. disconnected recordsets). If any of the data access methods is better suited for someone coming from my background, I might lean in that direction.
Thanks for any advice that you can offer!
Look at all three articles in this series:
High Performance Data Access Layer Architecture Part 1
Great advice.
You may want to look at decoupling the database layer from the asp layer so that you can not only give more flexbility in making the decision, but when you have to make changes to a customer's database you can just swap in a new dll without changing anything else.
By using dependency injection you can use xml to tell the framework which concrete class to use for an interface.
The advantage to doing this is that you can then go with one database approach, and if you later decide to change to another, then you can just change the dll and go on without making any changes to other layers.
Since you are more familiar with it why not just go directly to the database at the moment by making your own connections? Then you can move the rest of your code and along the way you can decide which of the myriad of technologies to use.
For a new application I am working on I am starting with LINQ to SQL for it, mainly because development will be quicker, but, later, if I decide that won't meet my needs I will just swap it out.
nHibernate might be a good fit. You can store the mapping in external configuration files which would solve your needs. Another option might be using ActiveRecord, which is based upon nHibernate.
nHibernate has a neat feature which you might find helpful. It's called a Dynamic property which is basically a name value pair collection populated by pulling the column names from the mapping file. So when you add a column at your client site, you update the mapping file and you'd be able to access the data through a collection on the object.