vs linq to oracle,Linq to Oracle and so on...

DbLinq Project: Linq Provider for MySql, Oracle and PostgreSQL

What is LINQ?

LINQ stands for Language-Integrated Query, which allows .NET programs (e.g. C# or VB.NET) to connect to databases.

It is an O/R (Object-Relational) mapping tool, with some similarities to Hibernate or LlblGen.  LINQ is type-safe, queries get compiled into MSIL on the fly, and your C# WHERE clauses are translated into SQL and sent to SQL server for execution. In short, it makes design of data access layers safer and faster. In C# 3.0, linq code looks like this:

var q = from p in db.Products

where p.ProductName == "Pen"

select p.ProductID;

Download

Latest source code is in subversion on code.google.com: svn page

Zipped releases are on the downloads page.

Coming in 2008 Feb:

Douglas Six from France has ported the provider to SqlLite. Peter Magnusson from Sweden maintains it - thanks to both!

Status Update - 2008 Jan:

下面是一个使用Oracle.ManagedDataAccess批量插入数据的完整例子: ```csharp using Oracle.ManagedDataAccess.Client; using System; using System.Collections.Generic; using System.Data; using System.Linq; namespace OracleBulkInsertExample { class Program { static void Main(string[] args) { string connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE)));User Id=hr;Password=hr;"; // 构建数据表和数据集 DataTable employeesTable = new DataTable(); employeesTable.Columns.Add("ID", typeof(int)); employeesTable.Columns.Add("NAME", typeof(string)); employeesTable.Columns.Add("AGE", typeof(int)); employeesTable.Columns.Add("SALARY", typeof(double)); employeesTable.Rows.Add(1, "John Smith", 35, 5000.50); employeesTable.Rows.Add(2, "Mary Johnson", 28, 4000.75); employeesTable.Rows.Add(3, "Peter Lee", 42, 7000.25); employeesTable.Rows.Add(4, "Kim Chen", 31, 5500.00); DataSet employeesDataSet = new DataSet(); employeesDataSet.Tables.Add(employeesTable); // 使用批量插入将数据插入到数据库中 using (OracleConnection connection = new OracleConnection(connectionString)) { connection.Open(); OracleCommand command = new OracleCommand("INSERT INTO EMPLOYEES(ID, NAME, AGE, SALARY) VALUES(:ID, :NAME, :AGE, :SALARY)", connection); command.ArrayBindCount = employeesTable.Rows.Count; command.Parameters.Add(":ID", OracleDbType.Int32, employeesTable.AsEnumerable().Select(r => r.Field<int>("ID")).ToArray(), ParameterDirection.Input); command.Parameters.Add(":NAME", OracleDbType.Varchar2, employeesTable.AsEnumerable().Select(r => r.Field<string>("NAME")).ToArray(), ParameterDirection.Input); command.Parameters.Add(":AGE", OracleDbType.Int32, employeesTable.AsEnumerable().Select(r => r.Field<int>("AGE")).ToArray(), ParameterDirection.Input); command.Parameters.Add(":SALARY", OracleDbType.Double, employeesTable.AsEnumerable().Select(r => r.Field<double>("SALARY")).ToArray(), ParameterDirection.Input); int rowsAffected = command.ExecuteNonQuery(); Console.WriteLine($"{rowsAffected} rows inserted."); } Console.ReadLine(); } } } ``` 在上面的例子中,我们首先创建了一个包含员工信息的数据表和数据集。然后,我们使用Oracle.ManagedDataAccess客户端连接到Oracle数据库,并使用批量插入将数据插入到数据库中。 请注意,我们使用OracleCommand的ArrayBindCount属性指定要插入的行数,然后使用参数化查询和数组绑定技术将数据传递给INSERT语句。 最后,我们输出插入的行数,然后关闭数据库连接。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值