Ejemplo n.º 1
0
        private void AppendProperties()
        {
            sb.AppendLine("		#region Properties");
            sb.AppendLine();

            foreach (var column in _item.GetColumns().Where(x => x.Generated).OrderBy(x => x.Name))
            {
                sb.AppendLine("		/// <summary>");
                if (!string.IsNullOrEmpty(column.Description))
                {
                    StringHelper.LineBreakCode(sb, column.Description, "		/// ");
                }
                else
                {
                    sb.AppendLine("		/// The property for the field '"+ column.DatabaseName + "'");
                }
                sb.AppendLine("		/// </summary>");
                sb.Append("		"+ column.GetCodeType() + " " + column.PascalName);
                sb.AppendLine(" { get; }");
                sb.AppendLine();
            }

            sb.AppendLine("		#endregion");
            sb.AppendLine();
        }
        //private void AppendedFieldEnum()
        //{
        //    var imageColumnList = _item.GetColumnsByType(System.Data.SqlDbType.Image);
        //    if (imageColumnList.Count() != 0)
        //    {
        //        sb.AppendLine("		#region FieldImageConstants Enumeration");
        //        sb.AppendLine();
        //        sb.AppendLine("		/// <summary>");
        //        sb.AppendLine("		/// An enumeration of this object's image type fields");
        //        sb.AppendLine("		/// </summary>");
        //        sb.AppendLine("		public enum FieldImageConstants");
        //        sb.AppendLine("		{");
        //        foreach (var column in imageColumnList.OrderBy(x => x.Name))
        //        {
        //            sb.AppendLine("			/// <summary>");
        //            sb.AppendLine("			/// Field mapping for the image parameter '" + column.PascalName + "' property");
        //            sb.AppendLine("			/// </summary>");
        //            sb.AppendLine("			[System.ComponentModel.Description(\"Field mapping for the image parameter '" + column.PascalName + "' property\")]");
        //            sb.AppendLine("			" + column.PascalName + ",");
        //        }
        //        sb.AppendLine("		}");
        //        sb.AppendLine();
        //        sb.AppendLine("		#endregion");
        //        sb.AppendLine();
        //    }

        //    sb.AppendLine("		#region FieldNameConstants Enumeration");
        //    sb.AppendLine();
        //    sb.AppendLine("		/// <summary>");
        //    sb.AppendLine("		/// Enumeration to define each property that maps to a database field for the '" + _item.PascalName + "' table.");
        //    sb.AppendLine("		/// </summary>");
        //    sb.AppendLine("		public enum FieldNameConstants");
        //    sb.AppendLine("		{");
        //    foreach (var column in _item.GeneratedColumns)
        //    {
        //        sb.AppendLine("			/// <summary>");
        //        sb.AppendLine("			/// Field mapping for the '" + column.PascalName + "' property" + (column.PascalName != column.DatabaseName ? " (Database column: " + column.DatabaseName + ")" : string.Empty));
        //        sb.AppendLine("			/// </summary>");
        //        sb.AppendLine("			[System.ComponentModel.ReadOnlyAttribute(true)]");
        //        sb.AppendLine("			[System.ComponentModel.Description(\"Field mapping for the '" + column.PascalName + "' property\")]");
        //        sb.AppendLine("			" + column.PascalName + ",");
        //    }

        //    sb.AppendLine("		}");
        //    sb.AppendLine("		#endregion");
        //    sb.AppendLine();
        //}

        private void AppendProperties()
        {
            sb.AppendLine("		#region Primitive Properties");
            sb.AppendLine();

            foreach (var column in _item.GetColumns())
            {
                sb.AppendLine("		/// <summary>");
                sb.AppendLine("		/// ");
                sb.AppendLine("		/// </summary>");
                sb.AppendLine("		[EdmScalarPropertyAttribute(EntityKeyProperty = false, IsNullable = true)]");
                sb.AppendLine("		[DataMemberAttribute()]");
                sb.AppendLine("		public "+ column.GetCodeType() + " " + column.PascalName);
                sb.AppendLine("		{");
                sb.AppendLine("			get { return _"+ column.CamelName + "; }");
                sb.AppendLine("			protected set");
                sb.AppendLine("			{");
                //sb.AppendLine("				On" + column.PascalName + "Changing(value);");
                //sb.AppendLine("				ReportPropertyChanging(\"" + column.PascalName + "\");");

                if (column.IsTextType || column.IsBinaryType || column.DataType == System.Data.SqlDbType.Timestamp)
                {
                    sb.AppendLine("				_"+ column.CamelName + " = StructuralObject.SetValidValue(value, true);");
                }
                else
                {
                    sb.AppendLine("				_"+ column.CamelName + " = StructuralObject.SetValidValue(value);");
                }

                //sb.AppendLine("				ReportPropertyChanged(\"" + column.PascalName + "\");");
                //sb.AppendLine("				On" + column.PascalName + "Changed();");
                sb.AppendLine("			}");
                sb.AppendLine("		}");
                sb.AppendLine("		private "+ column.GetCodeType() + " _" + column.CamelName + ";");
                //sb.AppendLine("		partial void On" + column.PascalName + "Changing(" + column.GetCodeType() + " value);");
                //sb.AppendLine("		partial void On" + column.PascalName + "Changed();");
                sb.AppendLine();
            }

            sb.AppendLine("		#endregion");
            sb.AppendLine();
        }