当前位置: 首页>>代码示例>>C#>>正文


C# Column.GetCodeType方法代码示例

本文整理汇总了C#中Column.GetCodeType方法的典型用法代码示例。如果您正苦于以下问题:C# Column.GetCodeType方法的具体用法?C# Column.GetCodeType怎么用?C# Column.GetCodeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Column的用法示例。


在下文中一共展示了Column.GetCodeType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendRegionSearchableSingleField

		private void AppendRegionSearchableSingleField(Column column)
		{
			sb.AppendLine("	#region " + _currentComponent.PascalName + "SelectBy" + column.PascalName);
			sb.AppendLine();
			sb.AppendLine("	/// <summary>");
			sb.AppendLine("	/// Select command used to perform selects by field '" + column.PascalName + "'");
			sb.AppendLine("	/// </summary>");
			sb.AppendLine("	[Serializable]");
			sb.AppendLine("	public partial class " + _currentComponent.PascalName + "SelectBy" + column.PascalName + " : SelectCommand, ISerializable");
			sb.AppendLine("	{");
			sb.AppendLine("		private " + column.GetCodeType() + " m" + column.PascalName + "; ");
			sb.AppendLine("		private " + _currentComponent.PascalName + "Paging _paging = null;");
			sb.AppendLine("		private int mCount = -1;");
			sb.AppendLine();
			sb.AppendLine("		#region Serialization");
			sb.AppendLine();
			sb.AppendLine("		/// <summary>");
			sb.AppendLine("		/// Serialization constructor");
			sb.AppendLine("		/// </summary>");
			sb.AppendLine("		protected " + _currentComponent.PascalName + "SelectBy" + column.PascalName + "(SerializationInfo info, StreamingContext context): base(info,context)");
			sb.AppendLine("		{");
			if (column.DataType == System.Data.SqlDbType.UniqueIdentifier)
				sb.AppendLine("			m" + column.PascalName + " = new Guid(info." + Globals.GetSerializationMethod(column.DataType) + "(\"m" + column.PascalName + "\"));");
			else
				sb.AppendLine("			m" + column.PascalName + " = info." + Globals.GetSerializationMethod(column.DataType) + "(\"m" + column.PascalName + "\");");
			sb.AppendLine("			_paging = (" + _currentComponent.PascalName + "Paging)info.GetValue(\"paging\", typeof(" + _currentComponent.PascalName + "Paging));");
			sb.AppendLine("		}");
			sb.AppendLine();
			sb.AppendLine("		/// <summary>");
			sb.AppendLine("		/// Method used internally for serialization");
			sb.AppendLine("		/// </summary>");
			sb.AppendLine("		public override void GetObjectData(SerializationInfo info, StreamingContext context)");
			sb.AppendLine("		{");
			sb.AppendLine("			base.GetObjectData(info, context);");
			sb.AppendLine("			info.AddValue(\"m" + column.PascalName + "\", m" + column.PascalName + ");");
			sb.AppendLine("			info.AddValue(\"paging\", _paging);");
			sb.AppendLine("		}");
			sb.AppendLine();
			sb.AppendLine("		#endregion ");
			sb.AppendLine();
			sb.AppendLine("		/// <summary>");
			sb.AppendLine("		/// The total number of rows returned. This is populated after the database is queried.");
			sb.AppendLine("		/// </summary>");
			sb.AppendLine("		public int Count");
			sb.AppendLine("		{");
			sb.AppendLine("		  get { return mCount; }");
			sb.AppendLine("		}");
			sb.AppendLine();
			sb.AppendLine("		/// <summary>");
			sb.AppendLine("		/// Select command that allows for the selection by field of database rows");
			sb.AppendLine("		/// </summary>");
			sb.AppendLine("		public " + _currentComponent.PascalName + "SelectBy" + column.PascalName + "(" + column.GetCodeType() + " " + column.CamelName + ")");
			sb.AppendLine("		{");
			sb.AppendLine("			m" + column.PascalName + " = " + column.CamelName + "; ");
			sb.AppendLine("		}");
			sb.AppendLine();
			sb.AppendLine("		/// <summary>");
			sb.AppendLine("		/// Select command that allows for the paged selection by field of database rows");
			sb.AppendLine("		/// </summary>");
			sb.AppendLine("		public " + _currentComponent.PascalName + "SelectBy" + column.PascalName + "(" + column.GetCodeType() + " " + column.CamelName + ", " + _currentComponent.PascalName + "Paging paging)");
			sb.AppendLine("				:this(" + column.CamelName + ")");
			sb.AppendLine("		{");
			sb.AppendLine("			_paging = paging; ");
			sb.AppendLine("		}");
			sb.AppendLine();
			sb.AppendLine("		/// <summary>");
			sb.AppendLine("		/// Creates a persistable domainCollection");
			sb.AppendLine("		/// </summary>");
			sb.AppendLine("		public override IDomainCollection CreateDomainCollection()");
			sb.AppendLine("		{");
			sb.AppendLine("			Domain" + _currentComponent.PascalName + "Collection colDomain = new Domain" + _currentComponent.PascalName + "Collection();");
			sb.AppendLine("			return colDomain;");
			sb.AppendLine("		}");
			sb.AppendLine();
			sb.AppendLine("		/// <summary>");
			sb.AppendLine("		/// The stored procedure name to select values to populate a '" + _currentComponent.PascalName + "' collection in a paged fashion");
			sb.AppendLine("		/// </summary>");
			sb.AppendLine("		public override string StoredProcedureName");
			sb.AppendLine("		{");
			sb.AppendLine("			get { return \"gen_" + _currentComponent.PascalName + "SelectBy" + column.PascalName + "\"; }");
			sb.AppendLine("		}");
			sb.AppendLine();
			sb.AppendLine("		/// <summary>");
			sb.AppendLine("		/// Initializes the parameters for this select command");
			sb.AppendLine("		/// </summary>");
			sb.AppendLine("		protected override void SetupParameterValues(SubDomainBase subDomain)");
			sb.AppendLine("		{");
			sb.AppendLine("			if (_paging != null)");
			sb.AppendLine("			{");
			sb.AppendLine("				if (_paging.OrderByList.Count != 1)");
			sb.AppendLine("					throw new Exception(\"The select operation supports exactly one OrderBy field.\");");
			sb.AppendLine();
			sb.AppendLine("				ParameterValues.Add(\"@paging_Ascending\", _paging.OrderByList[0].Ascending);");
			sb.AppendLine("				ParameterValues.Add(\"@paging_OrderByColumn\", " + _currentComponent.PascalName + "Collection.GetDatabaseFieldName(_paging.OrderByList[0].Field));");
			sb.AppendLine("				ParameterValues.Add(\"@paging_PageIndex\", _paging.PageIndex);");
			sb.AppendLine("				ParameterValues.Add(\"@paging_RecordsperPage\", _paging.RecordsperPage);");
			sb.AppendLine("			}");
			sb.AppendLine();
			sb.AppendLine("		}");
			sb.AppendLine();
//.........这里部分代码省略.........
开发者ID:nHydrate,项目名称:nHydrate,代码行数:101,代码来源:SelectComponentCommandGeneratedTemplate.cs

示例2: InitColumnText

		protected string InitColumnText(Column dbColumn)
		{
			string dataColumnCreation = String.Format("\t\t\tthis.column{0} = new DataColumn(\"{1}\", typeof({2}), null, System.Data.MappingType.Element);", dbColumn.PascalName, dbColumn.DatabaseName, dbColumn.GetCodeType(false));
			string addColumnToCollection = String.Format("\t\t\tbase.Columns.Add(this.column{0});", dbColumn.PascalName);
			string setAllowDbNullFalse = String.Format("\t\t\tthis.column{0}.AllowDBNull = false;", dbColumn.PascalName);
			string setDefaultAsSuppliedDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = {1};", dbColumn.PascalName, PrepareDefault(dbColumn));
			string setDefaultAsTypeDefault = "";
			if ((dbColumn.DataType == System.Data.SqlDbType.UniqueIdentifier) && (dbColumn.Default.Length == 36))
			{
				//setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = new Guid(\"{1}\");", dbColumn.PascalName, GetDefaultForRequiredParam(dbColumn.GetCodeType(false)));
				setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = " + GetDefaultForRequiredParam(dbColumn.GetCodeType(false)) + ";", dbColumn.PascalName);
			}
			else if (ModelHelper.IsTextType(dbColumn.DataType))
			{
				string dv = GetDefaultForRequiredParam(dbColumn.GetCodeType(false));
				if (dv == "string.Empty")
					dv = "";
				setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = \"{1}\";", dbColumn.PascalName, dv);
			}
			else if ((dbColumn.DataType == System.Data.SqlDbType.DateTime) || (dbColumn.DataType == System.Data.SqlDbType.SmallDateTime))
			{
				if (dbColumn.Default == "getdate")
				{
					setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = DateTime.Now;", dbColumn.PascalName);
				}
				else if (dbColumn.Default.StartsWith("getdate+"))
				{
					string t = dbColumn.Default.Substring(8, dbColumn.Default.Length - 8);
					string[] tarr = t.Split('-');
					if (tarr.Length == 2)
					{
						if (tarr[1] == "year")
							setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = DateTime.Now.AddYears(" + tarr[0] + ");", dbColumn.PascalName);
						else if (tarr[1] == "month")
							setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = DateTime.Now.AddMonths(" + tarr[0] + ");", dbColumn.PascalName);
						else if (tarr[1] == "day")
							setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = DateTime.Now.AddDays(" + tarr[0] + ");", dbColumn.PascalName);
					}
				}
				else
				{
					setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = new DateTime(1753, 1, 1);", dbColumn.PascalName);
				}

			}
			else if (dbColumn.EnumType == "")
				setDefaultAsTypeDefault = String.Format("\t\t\tthis.column{0}.DefaultValue = {1};", dbColumn.PascalName, GetDefaultForRequiredParam(dbColumn.GetCodeType(false)));

			string setReadOnly = String.Format("\t\t\tthis.column{0}.ReadOnly = true;", dbColumn.PascalName);
			string setAutoIncrement = String.Format("\t\t\tthis.column{0}.AutoIncrement = true;", dbColumn.PascalName);
			string setAutoIncrementSeed = String.Format("\t\t\tthis.column{0}.AutoIncrementSeed = -1;", dbColumn.PascalName);
			string setAutoIncrementStep = String.Format("\t\t\tthis.column{0}.AutoIncrementStep = -1;", dbColumn.PascalName);
			//TODO: string setUnique = this.columnTestGuid.Unique = true;

			StringBuilder returnText = new StringBuilder();
			returnText.AppendLine(dataColumnCreation);
			returnText.AppendLine(addColumnToCollection);

			//set allow null
			if (!dbColumn.AllowNull)
			{
				returnText.AppendLine(setAllowDbNullFalse);
			}

			//set default
			if (dbColumn.Default != string.Empty)
			{
				//returnText.AppendLine(setDefaultAsSuppliedDefault);
				returnText.AppendLine(setDefaultAsTypeDefault);
			}
			else if (!dbColumn.AllowNull && (dbColumn.Identity == IdentityTypeConstants.None))
			{
				returnText.AppendLine(setDefaultAsTypeDefault);
			}

			//set identity
			if (dbColumn.Identity == IdentityTypeConstants.Database)
			{
				returnText.AppendLine(setAutoIncrement);
				returnText.AppendLine(setAutoIncrementSeed);
				returnText.AppendLine(setAutoIncrementStep);
			}

			//return string
			return returnText.ToString();
		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:86,代码来源:DomainComponentCollectionGeneratedTemplate.cs

示例3: AppendMethodRetiveBySearchableFieldsSingleField

		private void AppendMethodRetiveBySearchableFieldsSingleField(Column column, bool isNew)
		{
			if (column.IsSearchable)
			{
				sb.AppendLine("		/// <summary>");
				sb.AppendLine("		/// Select an object list by '" + column.PascalName + "' field.");
				sb.AppendLine("		/// <param name=\"" + column.CamelName + "\">The " + column.CamelName + " field</param>");
				sb.AppendLine("		/// </summary>");
				sb.AppendLine("		public static " + (isNew ? "new " : "") + _currentTable.PascalName + "Collection SelectBy" + column.PascalName + "(" + column.GetCodeType() + " " + column.CamelName + ")");
				sb.AppendLine("		{");
				sb.AppendLine("			return SelectBy" + column.PascalName + "(" + column.CamelName + ", \"\");");
				sb.AppendLine("		}");
				sb.AppendLine();
				sb.AppendLine("		/// <summary>");
				sb.AppendLine("		/// Select an object list by '" + column.PascalName + "' field.");
				sb.AppendLine("		/// <param name=\"" + column.CamelName + "\">The " + column.CamelName + " field</param>");
				sb.AppendLine("		/// <param name=\"modifier\">The identifier used for the create and modify audits.</param>");
				sb.AppendLine("		/// </summary>");
				sb.AppendLine("		public static " + (isNew ? "new " : "") + _currentTable.PascalName + "Collection SelectBy" + column.PascalName + "(" + column.GetCodeType() + " " + column.CamelName + ", string modifier)");
				sb.AppendLine("		{");
				sb.AppendLine("			return SelectBy" + column.PascalName + "(" + column.CamelName + ", null, modifier);");
				sb.AppendLine("		}");
				sb.AppendLine();
				sb.AppendLine("		/// <summary>");
				sb.AppendLine("		/// Select an object list by '" + column.PascalName + "' field.");
				sb.AppendLine("		/// <param name=\"" + column.CamelName + "\">The " + column.CamelName + " field</param>");
				sb.AppendLine("		/// <param name=\"paging\">The paging object to determine how the results are paged.</param>");
				sb.AppendLine("		/// <param name=\"modifier\">The identifier used for the create and modify audits.</param>");
				sb.AppendLine("		/// </summary>");
				sb.AppendLine("		public static " + (isNew ? "new " : "") + _currentTable.PascalName + "Collection SelectBy" + column.PascalName + "(" + column.GetCodeType() + " " + column.CamelName + ", " + _currentTable.PascalName + "Paging paging, string modifier)");
				sb.AppendLine("		{");
				sb.AppendLine("			try");
				sb.AppendLine("			{");
				if (_model.Database.AllowZeroTouch)
				{
					sb.AppendLine("			  return " + _currentTable.PascalName + "Collection.RunSelect(x => x." + column.PascalName + " == " + column.CamelName + ", paging, modifier);");
				}
				else
				{
					sb.AppendLine("			  SubDomain sd = new SubDomain(modifier);");
					sb.AppendLine("			  " + _currentTable.PascalName + "SelectBy" + column.PascalName + " command = new " + _currentTable.PascalName + "SelectBy" + column.PascalName + "(" + column.CamelName + ", paging);");
					sb.AppendLine("			  sd.AddSelectCommand(command);");
					sb.AppendLine("			  sd.RunSelectCommands();");
					sb.AppendLine("			  if (paging != null) paging.RecordCount = command.Count;");
					sb.AppendLine("			  return (" + _currentTable.PascalName + "Collection)sd[Collections." + _currentTable.PascalName + "Collection];");
				}
				sb.AppendLine("			}");
				Globals.AppendBusinessEntryCatch(sb);
				sb.AppendLine("		}");
				sb.AppendLine();
			}

			if (column.IsSearchable && column.IsRangeType)
			{
				string var1 = column.CamelName + "Start";
				string var2 = column.CamelName + "End";
				sb.AppendLine("		/// <summary>");
				sb.AppendLine("		/// Select an object list by range by '" + column.PascalName + "' field.");
				sb.AppendLine("		/// </summary>");
				sb.AppendLine("		/// <param name=\"" + var1 + "\">The inclusive starting point of the range.</param>");
				sb.AppendLine("		/// <param name=\"" + var2 + "\">The inclusive ending point of the range.</param>");
				sb.AppendLine("		/// <param name=\"modifier\">The identifier used for the create and modify audits.</param>");
				sb.AppendLine("		public static " + (isNew ? "new " : "") + _currentTable.PascalName + "Collection SelectBy" + column.PascalName + "Range(" + column.GetCodeType() + " " + var1 + ", " + column.GetCodeType() + " " + var2 + ", string modifier)");
				sb.AppendLine("		{");
				sb.AppendLine("			return SelectBy" + column.PascalName + "Range(" + column.CamelName + "Start, " + column.CamelName + "End, null, modifier);");
				sb.AppendLine("		}");
				sb.AppendLine();
				sb.AppendLine("		/// <summary>");
				sb.AppendLine("		/// Select a paged object list by range by '" + column.PascalName + "' field.");
				sb.AppendLine("		/// </summary>");
				sb.AppendLine("		/// <param name=\"" + var1 + "\">The inclusive starting point of the range.</param>");
				sb.AppendLine("		/// <param name=\"" + var2 + "\">The inclusive ending point of the range.</param>");
				sb.AppendLine("		/// <param name=\"paging\">The paging object to determine how the results are paged.</param>");
				sb.AppendLine("		/// <param name=\"modifier\">The identifier used for the create and modify audits.</param>");
				sb.AppendLine("		public static " + (isNew ? "new " : "") + _currentTable.PascalName + "Collection SelectBy" + column.PascalName + "Range(" + column.GetCodeType() + " " + var1 + ", " + column.GetCodeType() + " " + var2 + ", " + _currentTable.PascalName + "Paging paging, string modifier)");
				sb.AppendLine("		{");
				sb.AppendLine("			try");
				sb.AppendLine("			{");
				sb.AppendLine("			  SubDomain sd = new SubDomain(modifier);");
				sb.AppendLine("			  " + _currentTable.PascalName + "SelectBy" + column.PascalName + "Range command = new " + _currentTable.PascalName + "SelectBy" + column.PascalName + "Range(" + column.CamelName + "Start, " + column.CamelName + "End, paging);");
				sb.AppendLine("			  sd.AddSelectCommand(command);");
				sb.AppendLine("			  sd.RunSelectCommands();");
				sb.AppendLine("			  if (paging != null) paging.RecordCount = command.Count;");
				sb.AppendLine("			  return (" + _currentTable.PascalName + "Collection)sd[Collections." + _currentTable.PascalName + "Collection];");
				sb.AppendLine("			}");
				Globals.AppendBusinessEntryCatch(sb);
				sb.AppendLine("		}");
				sb.AppendLine();
			}
		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:90,代码来源:BusinessCollectionGeneratedTemplate.cs

示例4: PrepareDefault

		private string PrepareDefault(Column dbColumn)
		{
			if (dbColumn.GetCodeType() == "string" && dbColumn.Default != string.Empty)
			{
				return ("\"" + dbColumn.Default + "\"");
			}
			else if (dbColumn.GetCodeType() == "System.DateTime" && dbColumn.Default.CompareTo("getdate") == 0)
			{
				return "DateTime.Now";
			}
			else if (dbColumn.GetCodeType() == "System.DateTime" && dbColumn.Default.CompareTo("getutcdate") == 0)
			{
				return ("DateTime.UtcNow");
			}
			else if (dbColumn.GetCodeType() == "System.Guid" && dbColumn.Default.StartsWith("newid"))
			{
				return ("System.Guid.NewGuid()");
			}
			else
			{
				return dbColumn.Default;
			}
		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:23,代码来源:DomainComponentCollectionGeneratedTemplate.cs


注:本文中的Column.GetCodeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。