linq to sql生成not in语句的小技巧
以前一直觉得linq to sql生成类似where id not in (1,3,5)或where id not in (select id from ...)这样的条件不是很方便,每次我都是把条件ID事先取到一个数组里,然后用 !Arr.Contains(c.Id)这样处理,今天突然发现这样好傻,其实可以完全直接用linq写成一句,贴个示例在这里,以后备查
from a in TableA where !(from b in TableB Where ... select b.Id).Contains(a.Id)
最终翻译出来的语句并非跟not in 完全一样的,而是用not exists(...),不过效果完全相同,能达到要求就行了!
相关文档:
4、对象依赖性
CREATE OR REPLACE TYPE Obj1 AS OBJECT (
f1 NUMBER,
f2 VARCHAR2(10),
f3 DATE
);
/
CREATE OR REPLACE TYPE Obj2 AS OBJECT (
f1 DATE,
f2 CHAR(1)
);
/
CREATE OR REPLACE TYPE Obj3 AS OBJECT (
a Obj1,
b Obj2
);
/
OBJ3依赖于OBJ ......
GRANT
Name
GRANT -- 定义访问权限
Synopsis GRANT { { SELECT | INSERT | UPDATE | DELETE | RULE | REFERENCES | TRIGGER }
[,...] | ALL [ PRIVILEGES ] }
ON [ TABLE ] tablename [, ...]
TO { username | GROUP groupname | PUBLIC } [, ...] [ WI ......
Merge statement
function benefits: 1) provides the ability to conditionally update, insert or delete data into a database table. 2) performs an update if the row exists, and an insert if it is a new row. --> 1) avoids seperate updates, 2) increase performance and ease of use. 3) is useful in dat ......
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace DAL
{
......