/// <summary>
/// 生成Create Table 语句
/// </summary>
/// <param name="cols"></param>
/// <param name="tableName"></param>
/// <returns></returns>
private string GetCreateTableSql(FieldSetingList cols, string tableName)
{
List<string> colDefs = new List<string>();
colDefs.Add("OBJECT_ID nvarchar(38)");
for (int i = 0; i < cols.Count; i++)
{
string fieldName = cols[i].FieldName;
string fieldType = "text";
switch (cols[i].FieldType)
{
case "System.String":
fieldType = string.Format("nvarchar({0})", cols[i].FieldLenth);
break;
case "System.Decimal": //??????????????????
fieldType = "integer";
break;
default:
break;
}
colDefs.Add(string.Format("{0} {1}", fieldName, fieldType));
}
string result = string.Format("create table {0} ({1})"
, tableName
, string.Join(",", colDefs.ToArray()));
return result;
}