There are two DB data table structure:
/*==============================================================*/
/* Table: Branch */
/*==============================================================*/
The create table Branch (
BranchId int identity,
Branno nvarchar (8) not null,
Branna nvarchar (30) not null,
Null, Principal nvarchar (8)
Null Preno nvarchar (8),
ScopeId uniqueidentifier null,
Branpath nvarchar (200), null,
Brantype tinyint null,
Bransrc int null,
The constraint PK_Branch primary key nonclustered (BranchId),
The constraint AK_Branno unique clustered (Branno)
)
/*==============================================================*/
/* Table: SysUser */
/*==============================================================*/
The create table SysUser (
UserId int identity,
Logno nvarchar (16) not null,
Userna nvarchar (8) not null,
Userlev tinyint null,
Usertype tinyint null,
The Valid bit not null default (1),
Valdate datetime null,
The Pwd nvarchar (512), null,
Branno nvarchar (8) not null,
Null Jobno nvarchar (8),
Manno nvarchar (8) null,
Null, Creater nvarchar (8)
Createdt datetime null,
Remark nvarchar (40) null,
Projno nvarchar (14) null,
Fingdt nvarchar (1500), null,
Imgfile nvarchar (30) null,
Mailaddr nvarchar (200), null,
Locked bit null,
Lockdate datetime null,
The Lockman nvarchar (8) null,
Telno nvarchar (15) null,
Pwdtype tinyint null default (0),
The constraint PK_SysUser primary key nonclustered (UserId),
The constraint AK_Logno unique (Logno)
)
On DAL layer, the method of implementation is this:
///& lt; Summary>
///department information new
///& lt;/summary>
///& lt; Param name="obj" & gt;
///& lt; Returns>
Public static bool AddBranch Branch (obj)
{
Try
{
int result=0;
Using (CusProContext db=new CusProContext ())
{
Db. Branch. The Add (obj);
Result=the SaveChanges ();
}
Return result!=0? True, false;
}
The catch (Exception ex)
{
Throw the ex.
}
}
///& lt; Summary>
///register new account information
///& lt;/summary>
///& lt; Param name="sysUser" & gt;
///& lt; Returns>
Public static bool ExecUserSave (SysUser the userinfo)
{
Try
{
int result=0;
Using (CusProContext db=new CusProContext ())
{
Db. SysUser. Add (the userinfo);
Result=the SaveChanges ();
}
Return result!=0? True, false;
}
The catch (Exception ex)
{
Throw the ex.
}
}
By essentially a Profiler trace execution results look:
The exec sp_executesql N '
INSERT [dbo] [Branch] (
[Branno],
[Branna],
(Principal),
[Preno],
[ScopeId],
[Branpath],
[Brantype],
[Bransrc]
)
VALUES (@ 0, @ 1, @ 2, @ 3, @ 4, @ 5, @ 6, @ 7)
SELECT [BranchId]
The FROM [dbo] [Branch]
WHERE @ @ ROWCOUNT & gt; 0 AND [BranchId]=scope_identity () ', N '@ 0 nvarchar (8), @ 1 nvarchar (30), @ 2 nvarchar (8), @ 3 nvarchar (8), 4 uniqueidentifier @, @ 5 nvarchar (200), 6 tinyint, @ @ 7 int' @ 0=N '007-3' @ 1=N 'are the keys in the workers' @ 2=N' 122334 ', @ 3=N '007', 4='@ B64F4F5F - F18B - 428 - a - 97 - BC - D8E8EE59ACBE' @ 5=N China, r&d center, the company has the keys in workers' @ 6=2, @ 7=0
The exec sp_executesql N '
INSERT [dbo] [SysUser] (
[Logno],
.
)
VALUES (
@ 0,
@ 1,
.
)
SELECT [UserId] FROM [dbo] [SysUser]
WHERE @ @ ROWCOUNT & gt; 0
AND [UserId]=scope_identity () ',
N '@ 0 nvarchar (16),
@ 1 nvarchar (8),
@ 2 tinyint,
.
@ 15 tinyint ',
@ 0=N '090124',
@ 1=N 'Long Lei',
.
14=N '@,
Results should is like this:
I am really not understand, at the same time the table structure, the same DAL writing way,
A table, to record the top line, a table, in the parent department line tail, and this [ID] since the appreciation, different...
Please god to solve!
CodePudding user response:
This question, I have changed the two places:nullnullnullnullnullnullnullnull