How to batch insert lots of rows using Enterprise Library DAAB? - c#

How can I execute 1000s of INSERT queries using Enterprise Library DAAB? That is to say how can I insert lots of rows into a table using DAAB all at once efficiently? And without using a for-loop. Thanks.

Unfortunately, I'm not sure you can do that using the Enterprise Library DAAB without extending it. As an alternative you can use SqlBulkCopy.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx
EDIT
The Oracle Data Provider for .NET (ODP.NET) supports this via the Array Binding feature.
http://www.oracle.com/technetwork/issue-archive/2009/09-sep/o59odpnet-085168.html

Related

Bulk Insert and update performances C# "ADO.NET" Vs "Linq2SQL" Vs "EF-DataFirst approach"

I am writing a Azure Web job c# code for doing Bulk Insertion and Update in an existing Azure SQL Database.
Considering the performance which .NET data access technology should I select-ADO.NET/Linq2SQL/EF-DataFirst approach ?
Raw ADO.NET with SqlBulkCopy will alway give you the best performance, as the other technologies are abstraction layers on top of ADO.NET

How to do multiple insert as well update by using dapper .net?

How to do multiple insert (50000 record) as well update using dapper .net ?
Is it possible to use SqlBulkCopy to achieve this? If yes then how?
Is there any best way to implement multiple hierarchical insert or update using Dapper.net?
Technologies : C#, SQL Server 2012, Dapper.net
If you just want to insert: SqlBulkCopy should be fine; if you want an "upsert", I suggest table-valued-parameters (which dapper supports) and the merge t-sql operation
Dapper just simplifies ado.net; if you think of a way to do it in ado.net, dapper can probably make it easier for you; however, it sounds like multiple TVPs might suffice
If you are mean to OK and able to segregate insert and update entities separately then I would suggest to use Dapper.Contrib library provided by Dapper.Net guys themselves. It is available via nuget. It has worked very efficiently for my project.
Here is the link to their Github project page.

What database should I use for small dotnet Application?

I am developing a small application with ASP and C# in .NET and I want to have a small local database next to it where I can save and retrieve records by either SQL queries or Linq queries. I don't need anything powerful, just something to use instead of keeping records in .txt files.
So what's your suggestion?
Use SQLite
It does not have to be installed and is just a DB File and there are connectors to .Net available.
And you can use LINQ
I would go with either SQLLite or with XML since you are saying very small database.
And with xml you can use Linq to xml
You can use SQL CE or SQLite.
Best to use SQL Express edition since it comes for free. Try using .NET entity framework code first for rapid application development.
In any case application is very small consider using SQL express since you can write neat and clean stored procedures and can play with other database objects.
Please refer http://www.microsoft.com/sqlserver/en/us/editions/express.aspx for more details.
I'll consider SQLite for this purposes.
If you are more comfortable with MS tools, or for some reason (i.e. your company already has a well formed mdb database file) you can use MS Access too, for local and small applications.
I recommend you to use SQL Server Express, becuase
It is free to use and easy to install
You can easily use either Entity Framework or LINQ TO SQL to manipulate your data
It can easily communicate with your company's DB ( if it is also SQL Server), for example, one day in the future, you may need to test the replication.
No one's mentioned it yet so here it is. mySQL and the .Net mySQL client.
In your case I would consider the following:
XML if you don't with more than a couple hundred records in all tables. And #Ali mentioned already LINQ to XML what will be handy.
VistaDB, because it's 100% managed code and require deployment of just one small assembly for both 32- and 64-bit.
SQL CE, just because it's the most popular one. Of course, it supports LINQ and concurrency.
SQLite as an alternative for SQL CE :)
Don't go with SQL Express unless it's been already provided by your hoster. It increases complexity of distributing/installing of your solution.

What is the best method of .Net for access very large database?

Suppose that, I use Oracle database. If my table have a lot of data about 10k records. When I use OleDB to select data from that table in ASP.NET. It's very slow.
Is there any methods that better than OleDB Oracle client?
Accessing 10k rows is not much. If it is for analytical reasons that you want to make calculations based on the data, use Oracle Analytical functions. They are VERY powerfull. By the time you accessed all rows and passed them to the client to have the analysis done on the client, the analysis has already been done by Oracle.
Do the analysis as close to where your data is as possible: in the rdbms.
See
Dan's library
Oracle documentation
ask Tom
Oracle Data Provider for .NET is a native implementation.

one Library for multiDatabases

Im developing a windows forms application using C# 4.0 and that application is going to target different database engines like SQL, MySQL and Oracle i was wondering if there is a library that can talk to all the three engines instead of implementing my own layers for every one.
thanks in advance.
You could use an ORM tool; I like NHibernate But there are many more: see a list at wikipedia.
The problem is if you want to do anything remotely advanced (date arithmatic, generate primary keys, get the id of the last inserted record, pivot a table , use RANGE construct etc.) then both databases use completely different syntax.
The best solution (in the java world at least is either Ibatis or Hibernate) I know there is a .NET version of Hibernate I am not sure about Ibatis.
These libraries insulate your program from the various SQL dialects and provide a common API independent of the underlying database.
If you use the classes in System.Data.Common you can make your code database independent:
Writing Provider Independent Code in ADO.NET
I don't know C#, but I know it will have a library for ODBC.
It looks like MS has one here.
It's old, but actually it does the job just fine. Virtually every DB in existence provides an ODBC driver.
Checkout DbLinq.
DbLinq is THE LINQ provider that allows to use common databases with
an API close to Linq to SQL. It currently supports (by order of
appearance): MySQL, Oracle, PostgreSQL, SQLite, Ingres, Firebird...
And still SQL Server.

Categories