Linq

BLToolkit.NET

Business Logic Toolkit for .NET www.bltoolkit.net
 

Data providers supported.

Data Provider Provider Name Namespace Vendor
AccessDataProvider Access System.Data.OleDb Microsoft
DB2DataProvider DB2 IBM.Data.DB2 IBM
InformixDataProvider Informix IBM.Data.Informix IBM
FdpDataProvider Fdp FirebirdSql.Data.FirebirdClient Firebird
MySqlDataProvider MySql MySql.Data.MySqlClient Sun Microsystems
OdpDataProvider ODP Oracle.DataAccess.Client Oracle
PostgreSQLProvider PostgreSQL Npgsql PostgreSQL.org
SqlCeDataProvider SqlCe System.Data.SqlServerCe Microsoft
SQLiteDataProvider SQLite System.Data.SQLite SQLite.org
SqlDataProvider Sql System.Data.SqlClient Microsoft
SybaseDataProvider Sybase Sybase.Data.AseClient Sybase

Operators.

 LinqDB2InformixOracleFirebirdPostgreSQLMySqlMS SQLSqlCeSybaseSQLiteAccess
Bitwise ANDa & bBitAnd(a, b)Bin_And(a, b)a & bX
Bitwise ORa || bBitOr(a, b)(a + b) - BitAnd(a, b)Bin_Or(a, b)a || bX
Bitwise XORa ^ bBitXor(a, b)(a + b) - BitAnd(a, b) * 2Bin_Xor(a, b)a # ba ^ b(a + b) - (a & b) * 2X
Coalescea ?? bCoalesce(a, b)Nvl(a, b)Coalesce(a, b)Iif(a IS NULL, b, a)
a ?? b ?? cCoalesce(a, b, c)Nvl(a, b, c)Coalesce(a, b, c)Iif(a IS NULL, Iif(b IS NULL, c, b), a)
Concatenationa + b + ca || b || cConcat(a, b, c)a + b + ca || b || ca + b + c
Conditionala ? b : cCASE WHEN a THEN b ELSE c ENDIif(a, b, c)
a ? b : c ? d : eCASE WHEN a THEN b WHEN c THEN d ELSE e ENDIif(a, b, Iif(c, d, e))
Moduloa % bMod(a, b)a % ba MOD b

Core string functions.

 LinqDB2InformixOracleFirebirdPostgreSQLMySqlMS SQLSqlCeSybaseSQLiteAccess
CaseSql.Lower(s)Lower(s)LCase(s)
Sql.Upper(s)Upper(s)UCase(s)
CharIndexSql.CharIndex(a, s)Locate(a, s)XInStr(s, a)XPosition(a in s)Locate(a, s)CharIndex(a, s)InStr(1, s, a, 1)
Sql.CharIndex(a, s, b)Locate(a, s, b)XInStr(s, a, b)XPosition(a in Substring(s, b,
  Length(s)-b)) + b-1
Locate(a, s, b)CharIndex(a, s, b)CharIndex(a,Substring(
  s, b, Len(s)-b)) + b - 1
CharIndex(a, s, b)InStr(b, s, a, 1)
LengthSql.Length(s)Length(s)Char_Length(s)Length(s)Len(s)Length(s)Len(s)
LIKE!s.Contains(a)s NOT LIKE aNOT s LIKE as NOT LIKE a
s.Contains("a%b")s LIKE '%a~%b%' ESCAPE '~'s LIKE "%a[%]b%"
s.Contains("abc")s LIKE '%abc%'
s.Contains(str)s LIKE @str ESCAPE '~'s LIKE @str
s.EndsWith("abc")s LIKE '%abc'
s.StartsWith("abc")s LIKE 'abc%'
Sql.Like(s, "%abc%")s LIKE '%abc%'
Sql.Like(s, "a~%b", '~')s LIKE "a~%b" ESCAPE '~'s LIKE "a[%]b"
SqlMethods.Like(s, "%abc%")s LIKE '%abc%'
SqlMethods.Like(s, "a~%b", '~')s LIKE "a~%b" ESCAPE '~'s LIKE "a[%]b"
PadSql.PadLeft(s, a, b)VarChar(Repeat(b,
 a-Length(s)), 1000) || s
LPad(s, a, b)Replicate(b, a - Len(s)) + sString(a-Len(s), b)) + s
Sql.PadRight(s, a, b)s || VarChar(Repeat(
 b, a-Length(s)), 1000)
RPad(s, a, b)s + Replicate(b, a - Len(s))s + String(a-Len(s), b))
ReplaceSql.Replace(s, a, b)Replace(s, a, b)Str_Replace(s, a, b)Replace(s, a, b)X
ReverseSql.Reverse(s)XReverse(s)Reverse(s) -- implemented as UDFReverse(s)XReverse(s)X
SpaceSql.Space(a)VarChar(
 Repeat(' ', a), 1000)
RPad(' ', a, ' ')Repeat(' ', a)Space(a)PadR(' ', a)Space(a)
StuffSql.Stuff(s, a, b, c)Substring(s, 1, a-1) + c + Substring(s, a+b, Length(s)-a-b+1))Stuff(s, a, b, c)Substring(s, 1, a-1) + c +
Substring(s, a+b, Length(s)-a-b+1))
SubstringSql.Left(s, a)Left(s, a)Substr(s, 1, a)Left(s, a)Substring(s, 1, a)Left(s, a)Substring(s, 1, a)Left(s, a)LeftStr(s, a)Left(s, a)
Sql.Right(s, a)Right(s, a)Substr(s,
  Length(s)-a+1, a)
Right(s, a)Substring(s, Length(s)-a+1, a)Right(s, a)Substring(s,
  Len(s)-a+1, a)
Right(s, a)RigthStr(s, a)Right(s, a)
Sql.Substring(s, a, b)Substr(s, a, b)Substring(
 s from a for b)
Substring(s, a, b)Substr(s, a, b)Mid(s, a, b)
TrimSql.Trim(s)Trim(s)LTrim(RTrim(s))Trim(s)
Sql.TrimLeft(s)LTrim(s)
Sql.TrimRight(s)RTrim(s)

Extended Linq string functions.

To support methods listed below provider must implement all used functions.
 LinqAll data providers
Cases.ToLower ()Sql.Lower(s)
s.ToUpper ()Sql.Upper(s)
Compares.CompareTo (a)s > a ? 1 : s == 0 ? 0 : -1
IndexOfs.IndexOf (a)Sql.Length(a) == 0 ? 0 : (Sql.CharIndex(a, s) ?? 0) - 1
s.IndexOf (a, b)Sql.Length(a) == 0 && Sql.Length(s) > b ? b : (Sql.CharIndex(a, s, b + 1) ?? 0) - 1
s.IndexOf (a, b, c)Sql.Length(a) == 0 && Sql.Length(s) > b ? b : (Sql.CharIndex(a, Sql.Left(s, c), b) ?? 0) - 1
Inserts.Insert (a, b)Sql.Length(s) == a ? s + b : Sql.Stuff(s, a + 1, 0, b)
LastIndexOfs.LastIndexOf(a)Sql.Length(a) == 0 ? Sql.Length(s) - 1 :
(Sql.CharIndex(a, s) ?? 0) == 0 ? -1 :
  Sql.Length(s) - (Sql.CharIndex(Sql.Reverse(a), Sql.Reverse(s)) ?? 0) - Sql.Length(a) + 1
s.LastIndexOf(a, b)Sql.Length(a) == 0 ? b :
(Sql.CharIndex(a, s, b + 1) ?? 0) == 0 ? -1 :
  Sql.Length(s) - (Sql.CharIndex(Sql.Reverse(a), Sql.Reverse(Sql.Substring(s, b + 1, Sql.Length(s) - b))) ?? 0) - Sql.Length(a) + 1
s.LastIndexOf(a, b, c)Sql.Length(a) == 0 ? b :
(Sql.CharIndex(a, Sql.Left(s, b + c), b + 1) ?? 0) == 0 ? -1 :
  b + c - (Sql.CharIndex(Sql.Reverse(a), Sql.Reverse(Sql.Substring(s, b + 1, c))) ?? 0) - Sql.Length(a) + 1
Lengths.LengthSql.Length(s)
Pads.PadLeft (a)Sql.PadLeft(s, a, ' ')
s.PadLeft (a, b)Sql.PadLeft(s, a, b)
s.PadRight (a)Sql.PadRight(s, a, ' ')
s.PadRight (a, b)Sql.PadRight(s, a, b)
Removes.Remove (a)Sql.Left(s, a)
s.Remove (a, b)Sql.Stuff(s, a + 1, b, "")
Replaces.Replace (a, b)Sql.Replace(s, a, b)
Substrings.Substring (a)Sql.Substring(s, a + 1, Sql.Length(s) - a)
s.Substring (a, b)Sql.Substring(s, a + 1, b)
Trims.Trim ()Sql.Trim(s)
s.TrimEnd ()Sql.TrimRight(s)
s.TrimStart ()Sql.TrimLeft(s)

Core datetime functions.

 LinqDB2InformixOracleFirebirdPostgreSQLMySqlMS SQLSqlCeSybaseSQLiteAccess
Current TimestampSql.CurrentTimestampCURRENT_TIMESTAMPCURRENTCURRENT_TIMESTAMPGetDate()CURRENT_TIMESTAMPNow
Sql.GetDate()CURRENT_TIMESTAMPCURRENTCURRENT_TIMESTAMPGetDate()CURRENT_TIMESTAMPNow

Extended Linq datetime functions.

 LinqAll data providers
Current TimestampDateTime.NowSql.CurrentTimestamp

SQL transformations.

 LinqDB2InformixOracleFirebirdPostgreSQLMySqlMS SQLSqlCeSybaseSQLiteAccess
SELECT xdb.Select(() => x)
SELECT x 
FROM SYSIBM.SYSDUMMY1 
FETCH FIRST 1 ROW ONLY
SELECT FIRST 1 x
FROM SYSTABLES
SELECT x 
FROM SYS.DUAL
SELECT x 
FROM rdb$database
SELECT x
TAKE xquery.Take(x)
... FETCH FIRST x ROWS ONLY
SELECT FIRST x
... WHERE rownum <= x
SELECT FIRST x
... LIMIT x
SELECT TOP x
X
SELECT TOP x
... LIMIT x
SELECT TOP x
 
© 2010 www.bltoolkit.net
[email protected]