Browse Source

Optimized code

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
347b88546d
  1. 88
      Src/Asp.Net/SqlServerTest/Demos/CS_TeacherStudent.cs
  2. 1
      Src/Asp.Net/SqlServerTest/SqlServerTest.csproj
  3. 8
      Src/Asp.Net/SqlServerTest/UnitTest/Update.cs
  4. 4
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs

88
Src/Asp.Net/SqlServerTest/Demos/CS_TeacherStudent.cs

@ -0,0 +1,88 @@
using System;
using System.Linq;
using System.Text;
namespace OrmTest.Demo
{
public class CS_TeacherStudent
{
/// <summary>
/// Desc:-
/// Default:(newid())
/// Nullable:False
/// </summary>
public Guid tabId {get;set;}
/// <summary>
/// Desc:教师Id
/// Default:-
/// Nullable:False
/// </summary>
public string teacherId {get;set;}
/// <summary>
/// Desc:教师课程Id(对应TeacherCourse.tabId)
/// Default:-
/// Nullable:False
/// </summary>
public string teacherCourseId {get;set;}
/// <summary>
/// Desc:教学头内的序号
/// Default:-
/// Nullable:True
/// </summary>
public int? ordInTC {get;set;}
/// <summary>
/// Desc:学号
/// Default:-
/// Nullable:False
/// </summary>
public string stuId {get;set;}
/// <summary>
/// Desc:学生姓名
/// Default:-
/// Nullable:True
/// </summary>
public string stuName {get;set;}
/// <summary>
/// Desc:性别
/// Default:-
/// Nullable:True
/// </summary>
public string stuSex {get;set;}
/// <summary>
/// Desc:所属院系Id
/// Default:-
/// Nullable:True
/// </summary>
public string deptId {get;set;}
/// <summary>
/// Desc:所属班级Id
/// Default:-
/// Nullable:True
/// </summary>
public string classId {get;set;}
/// <summary>
/// Desc:不能对应班级代码的班级名称时源班级名称
/// Default:-
/// Nullable:True
/// </summary>
public string sclassName {get;set;}
/// <summary>
/// Desc:-
/// Default:((1))
/// Nullable:True
/// </summary>
public int? validFlag {get;set;}
}
}

1
Src/Asp.Net/SqlServerTest/SqlServerTest.csproj

@ -54,6 +54,7 @@
<Compile Include="Demos\8_JoinSql.cs" />
<Compile Include="Demos\5_DbFirst.cs" />
<Compile Include="Demos\4_Delete.cs" />
<Compile Include="Demos\CS_TeacherStudent.cs" />
<Compile Include="Demos\DemoBase.cs" />
<Compile Include="Demos\3_Insert.cs" />
<Compile Include="Demos\1_Query.cs" />

8
Src/Asp.Net/SqlServerTest/UnitTest/Update.cs

@ -116,10 +116,10 @@ namespace OrmTest.UnitTest
string name = "x";
var t10 = db.Updateable<Student>().UpdateColumns(it => new Student() { Name =name, SchoolId=updateObj.SchoolId }).Where(it=>it.Id==11).ToSql();
base.Check(@"UPDATE [STudent] SET
[SchoolId] = @Const0 , [Name] = @const3 WHERE ( [ID] = @Id1 )", new List<SugarParameter>() {
new SugarParameter("@const3","x"),
new SugarParameter("@Const0",18),
new SugarParameter("@Id1",11)},
[SchoolId] = @Const1 , [Name] = @Const0 WHERE ( [ID] = @Id2 )", new List<SugarParameter>() {
new SugarParameter("@Const1",18),
new SugarParameter("@Const0","x"),
new SugarParameter("@Id2",11)},
t10.Key,
t10.Value,
"Update 10 error"

4
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberInitExpressionResolve.cs

@ -59,9 +59,10 @@ namespace SqlSugar
{
base.Expression = item;
base.Start();
string parameterName = this.Context.SqlParameterKeyWord + "const" + this.ContentIndex;
string parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const+ this.Context.ParameterIndex;
parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
this.Context.Parameters.Add(new SugarParameter(parameterName, parameter.CommonTempData));
this.Context.ParameterIndex++;
}
else if (item is MethodCallExpression)
{
@ -79,7 +80,6 @@ namespace SqlSugar
base.Expression = item;
base.Start();
parameter.IsAppendResult();
string parameterName = this.Context.SqlParameterKeyWord + "const" + +this.ContentIndex; ;
parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameter.CommonTempData.ObjToString()));
base.Context.Result.CurrentParameter = null;
}

Loading…
Cancel
Save