private string EntityStruct() { var code = new StringBuilder(); bool isFirst = true; foreach (PropertyConfig col in Table.PublishProperty) { if (isFirst) { isFirst = false; } else { code.Append(','); } code.AppendFormat(@" {{ Real_{0}, new PropertySturct {{ Index = Index_{0}, PropertyName = ""{0}"", PropertyType = typeof({1}), CanNull = {2}, ValueType = PropertyValueType.{3} }} }}", col.PropertyName , col.CustomType ?? col.CsType , col.Nullable ? "true" : "false" , CodeBuilderDefault.PropertyValueType(col)); } var code2 = new StringBuilder(); foreach (PropertyConfig col in Table.PublishProperty) { code2.AppendFormat(@" public const byte Index_{0} = {1};", col.PropertyName, col.Index); } return(string.Format(@" {3} /// <summary> /// 实体结构 /// </summary> [IgnoreDataMember,Browsable (false)] public override EntitySturct __Struct {{ get {{ return __struct; }} }} /// <summary> /// 实体结构 /// </summary> [IgnoreDataMember] static readonly EntitySturct __struct = new EntitySturct {{ EntityName = ""{0}"", PrimaryKey = ""{1}"", Properties = new Dictionary<int, PropertySturct> {{{2} }} }}; " , Table.EntityName, Table.PrimaryColumn.PropertyName, code, code2)); }