SdtcnCoder源代码
SdtcnCoder参考了TheBeerHouse的系统结构,采用了三层结构和缓存技术,这里对SdtcnCoder代码生成进行简单介绍.
一、数据类型模型
1、 Field类是字段类型的基类,对SqlServer2005数据列属性进行了映射;
2、 BigInt、Binary等是具体类,如下Binary,主要重写各种数据类型在C#语法中的类型、默认值、字符类型时的长度等;
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
-
namespace Sdtcn.Coder
{
public class Binary : Field
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="row"></param>
public Binary (DataRow row) : base(row)
{
}
/// <summary>
/// 重写返回C#类型的方法
/// </summary>
public override string CSharpTypeName
{
get
{
return "Byte[]";
}
}
/// <summary>
/// 重写返回值
/// </summary>
public override string DefaultValue
{
get
{
return "null";
}
}
public override string Length
{
get
{
return "(" + this.Max_Length.ToString() + ")";
}
}
}
}
二、代码生成
代码生成主要由Table类负责,主要方法分为生成存储过程、生成DAL、生成BLL、生成Aspx(当前还没有实现,方法和生成BLL雷同)等几类,具体参见源代码。
三、操作界面
操作界面如下图示:

四、操作说明
安装完成后,需要配置安装目录下的UserConfigue.xml文件,默认为Windows信任的连接方式,数据库默认为AdventureWorks,如果需要自行更改。
五、存在问题
1、 目前Aspx前台代码生成部分还没有编写;
2、 设置模块还没有编写;
3、 对其它数据库(MySql、Oracle等)或语言(Java)的生成没有友好的接口;
4、 我还没有找到SqlServer中如何获取数据表的主键,只是把第一个字段简单认为是主键,因此很多时候还不能满足需求,希望各位大虾能给些指点;
5、 ……等待大家给些意见
SdtcnCoder参考了TheBeerHouse的系统结构,采用了三层结构和缓存技术,这里对SdtcnCoder代码生成进行简单介绍.
一、数据类型模型
1、 Field类是字段类型的基类,对SqlServer2005数据列属性进行了映射;
2、 BigInt、Binary等是具体类,如下Binary,主要重写各种数据类型在C#语法中的类型、默认值、字符类型时的长度等;
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
-
namespace Sdtcn.Coder
{
public class Binary : Field
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="row"></param>
public Binary (DataRow row) : base(row)
{
}
/// <summary>
/// 重写返回C#类型的方法
/// </summary>
public override string CSharpTypeName
{
get
{
return "Byte[]";
}
}
/// <summary>
/// 重写返回值
/// </summary>
public override string DefaultValue
{
get
{
return "null";
}
}
public override string Length
{
get
{
return "(" + this.Max_Length.ToString() + ")";
}
}
}
}
二、代码生成
代码生成主要由Table类负责,主要方法分为生成存储过程、生成DAL、生成BLL、生成Aspx(当前还没有实现,方法和生成BLL雷同)等几类,具体参见源代码。
三、操作界面
操作界面如下图示:
四、操作说明
安装完成后,需要配置安装目录下的UserConfigue.xml文件,默认为Windows信任的连接方式,数据库默认为AdventureWorks,如果需要自行更改。
五、存在问题
1、 目前Aspx前台代码生成部分还没有编写;
2、 设置模块还没有编写;
3、 对其它数据库(MySql、Oracle等)或语言(Java)的生成没有友好的接口;
4、 我还没有找到SqlServer中如何获取数据表的主键,只是把第一个字段简单认为是主键,因此很多时候还不能满足需求,希望各位大虾能给些指点;
5、 ……等待大家给些意见
浙公网安备 33010602011771号