易截截图软件、单文件、免安装、纯绿色、仅160KB

.NET学习手记之:linq to SQL(一)


一个简单的例子:
先建一个C#类:
引用System.Data.Linq.dll程序集,
using System.Data.Linq.Mapping和
using System.Data.Linq 两个空间。
[Table]
public class Inventory
{
   [Column]
   public string Make;
   [Column]
   public string Color;
   [Column]
   public string PetName;
  
   //指明主键。
   [Column(IsPrimaryKey = true)]
   public int CarID;
  
   public override string ToString()
   {
       return string.Format(
        "编号={0};制造商={1};颜色={2};爱称={3}",
         CarID,Make.Trim(),Color.Trim(),PetName.Trim());
   }
}
与SQL(express版)数据库交互:
class Program
{
   const string cnStr=
       @"Data Source=(local)\SQLEXPRESS;Initial Catalog=Autolot;"+
            "Integrated Security=True";
   static void Main(string[] args)
   {
       Console.WriteLine("*****LINQ to SQL 简单应用*****");
       //创建一个DataContext对象。
       DataContext db= new DataContext(cnStr);
       //创建一个Table<>泛型实例。
       Table<Inventory> invTable = db.GetTable<Inventory>();
       //用一个LINQ查询显示结果。
       foreach(var car in from c in invTable select c)
           Console.WriteLine(car.ToString());
   }
   Console.ReadLine();
}
对DataContext类进行扩展:
class MyAutoLotDatabase:DataContext
{
   public Table<Inventory> Inventory;
   public MyAut


相关文档:

Sql Server 2005 中的同义词与复制

在2005中有同义词与复制的概念
同义词的主要作用是:
        一:宿短对象的名称,减少工作人员书写的时间,提高效率。我们知道访问数据库一个对象的通常最全的对象名称是:服务器名称。数据库名称。架构名称。对象名称
        二:同步数据。 ......

解决SQL Server里sp_helptext输出格式错行问题

use Master 
go 
if object_id('SP_SQL') is not null 
  drop proc SP_SQL 
go 
create proc [dbo].[SP_SQL](@ObjectName sysname) 
as 
set nocount on ; 
declare @Print varchar(max) 
if exists(select 1 from syscomments  where ID=objec ......

sql isnull函数的使用


sql isnull函数的使用
ISNULL
使用指定的替换值替换 NULL。
语法
ISNULL ( check_expression , replacement_value )
参数
check_expression
将被检查是否为 NULL的表达式。check_expression 可以是任何类型的。
replacement_value
在 check_expression 为 NULL时将返回的表达式。replacement_value 必须与 chec ......

ORACLE SQL语句优化


1) 选择最有效率的表名顺序(只在基于规则的优化器中有效):
ORACLE的解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving table)将被最先处理,在from子句中包含多个表的情况下,你必须选择记录条数最少的表作为基础表。如果有3个以上的表连接查询, 那就需要选择交叉表(intersection ......

【SQL SERVER中一些特别地方的特别解法2】


/*----------------------------------------------------------------
-- Author  :feixianxxx(poofly)
-- Date    :2010-04-20 20:10:41
-- Version:
--      Microsoft SQL Server 2008 (SP1) -  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号