码迷,mamicode.com
首页 > 数据库 > 详细

SQL、LINQ、Lambda 三种用法

时间:2017-03-18 00:46:07      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:logs   varchar   单表   image   exp   foreign   har   数据表   put   

使用工具:LINQPad4

1.准备数据表  

Customer(顾客表)-- Id(自增主键)Name(顾客姓名)Phone(顾客联系方式)

技术分享
CREATE TABLE [dbo].[Customer](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](50) NULL,
    [Phone] [nvarchar](16) NULL,
 CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
顾客表建库脚本

Order(订单表)-- Id(自增主键)OrderName(订单名称)Content(订单内容)CustomerId(顾客id)

技术分享
CREATE TABLE [dbo].[Order](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [OrderName] [nvarchar](50) NULL,
    [Content] [nvarchar](256) NULL,
    [CustomerId] [int] NOT NULL,
 CONSTRAINT [PK_Order] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Order]  WITH CHECK ADD  CONSTRAINT [FK_CustomerOrder] FOREIGN KEY([CustomerId])
REFERENCES [dbo].[Customer] ([Id])
GO

ALTER TABLE [dbo].[Order] CHECK CONSTRAINT [FK_CustomerOrder]
订单表建库脚本

as

sa

as

as

s

s

 

SQL、LINQ、Lambda 三种用法

标签:logs   varchar   单表   image   exp   foreign   har   数据表   put   

原文地址:http://www.cnblogs.com/YK2012/p/6569117.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!