本文整理汇总了C#中IColumn类的典型用法代码示例。如果您正苦于以下问题:C# IColumn类的具体用法?C# IColumn怎么用?C# IColumn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IColumn类属于命名空间,在下文中一共展示了IColumn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAlterColumnStatement
public override string BuildAlterColumnStatement(IColumn column)
{
//SQLite doesn't support altering columns. There is no typing either, or length considerations
//so - unless we're adding/dropping, fuggedaboutit
//http://stackoverflow.com/questions/623044/how-to-alter-sqlite-column-iphone
return "";
}
示例2: AddColumn
public string AddColumn(IColumn column) {
var sql = new StringBuilder("alter table ");
this.dialect.AppendQuotedTableName(sql, column.Map);
sql.Append(" add ");
this.dialect.AppendColumnSpecification(sql, column);
return sql.ToString();
}
示例3: ModifyColumn
public override string ModifyColumn(IColumn fromColumn, IColumn toColumn) {
var sql = new StringBuilder();
// drop a column constraint if need be
if (!string.IsNullOrEmpty(fromColumn.Default) && !fromColumn.IsPrimaryKey && !fromColumn.IsAutoGenerated
&& (string.IsNullOrEmpty(toColumn.Default) || fromColumn.Default != toColumn.Default)) {
sql.AppendLine(this.OnBeforeDropColumn(fromColumn));
}
// alter the column
sql.Append("alter table ");
this.AppendQuotedTableName(sql, toColumn.Map);
sql.Append(" alter column ");
this.AppendColumnSpecification(sql, toColumn, false);
// add a column constraint if need be
if (!string.IsNullOrEmpty(toColumn.Default) && !toColumn.IsPrimaryKey && !toColumn.IsAutoGenerated) {
sql.AppendLine(";");
sql.Append("alter table ");
this.AppendQuotedTableName(sql, toColumn.Map);
sql.Append(" add default (");
sql.Append(toColumn.Default);
sql.Append(") for");
this.AppendQuotedName(sql, toColumn.DbName);
}
return sql.ToString();
}
示例4: To
public void To(IColumn column)
{
RemoveOldMapping();
if (column == null)
{
ms.InvalidateCache();
return;
}
var mapping = ms.GetMappingFor(property.Component);
if (mapping == null)
{
mapping = new ComponentMappingImpl();
mapping.ToComponent = property.Component;
mapping.FromTable = column.Parent;
mapping.AddPropertyAndColumn(property, column);
ms.AddMapping(mapping);
}
else
{
mapping.SetMapping(property, column);
ms.InvalidateCache();
}
}
示例5: GetUnobtrusiveValidationAttributes
public static IDictionary<string, object> GetUnobtrusiveValidationAttributes(IColumn column)
{
Dictionary<string, object> resultsDictionary = new Dictionary<string, object>();
string fullHtmlFieldName = column.Name;
IEnumerable<ModelClientValidationRule> enumerable = GetClientValidationRule(column);
bool flag = false;
foreach (ModelClientValidationRule rule in enumerable)
{
flag = true;
string dictionaryKey = "data-val-" + rule.ValidationType;
//ValidateUnobtrusiveValidationRule(rule, resultsDictionary, dictionaryKey);
resultsDictionary[dictionaryKey] = HttpUtility.HtmlEncode(rule.ErrorMessage ?? string.Empty);
dictionaryKey = dictionaryKey + "-";
foreach (KeyValuePair<string, object> pair in rule.ValidationParameters)
{
resultsDictionary[dictionaryKey + pair.Key] = pair.Value.ToString() ?? string.Empty;
}
}
if (flag)
{
resultsDictionary.Add("data-val", "true");
}
return resultsDictionary;
}
示例6: SetMappedColumn
public static void SetMappedColumn(this ComponentPropertyMarker property, IColumn column)
{
if (property == null) throw new ArgumentNullException("property");
var set = property.GetMappingSet();
if (set == null) throw new Exception(string.Format("Could not set Mapped Column for Property {0}: Could not get its MappingSet", property.PropertyName));
set.ChangeMappingFor(property).To(column);
}
示例7: GetClientValidationRule
private static IEnumerable<ModelClientValidationRule> GetClientValidationRule(IColumn column)
{
if (column.DataType == DataType.Int || column.DataType == DataType.Decimal)
{
yield return new ModelClientValidationRule()
{
ValidationType = "number",
ErrorMessage = string.Format(SR.GetString("ClientDataTypeModelValidatorProvider_FieldMustBeNumeric"), column.Name)
};
}
if (column.DataType == DataType.String && column.Length > 0)
{
yield return new ModelClientValidationStringLengthRule(string.Format(SR.GetString("StringLengthAttribute_ValidationError"), column.Name, column.Length)
, 0, column.Length);
}
if (!column.AllowNull)
{
yield return new ModelClientValidationRequiredRule(string.Format(SR.GetString("RequiredAttribute_ValidationError"), column.Name));
}
if (column.Validations != null)
{
foreach (var validation in column.Validations)
{
foreach (var clientValidation in validation.GetClientValidationRule(column.Name))
{
yield return clientValidation;
}
}
}
}
示例8: BuildAddColumnStatement
/// <summary>
/// Adds the column.
/// </summary>
/// <param name="tableName">Name of the table.</param>
/// <param name="column">The column.</param>
/// <returns></returns>
public virtual string BuildAddColumnStatement(string tableName, IColumn column)
{
var sql = new StringBuilder();
//if we're adding a Non-null column to the DB schema, there has to be a default value
//otherwise it will result in an error'
if (!column.IsNullable && column.DefaultSetting == null)
{
SetColumnDefaults(column);
}
sql.AppendFormat(ADD_COLUMN, tableName, column.Name, GenerateColumnAttributes(column));
//if the column isn't nullable and there are records already
//the default setting won't be honored and a null value could be entered (in SQLite for instance)
//enforce the default setting here
if(!column.IsNullable)
{
sql.AppendLine();
var defaultValue = column.DefaultSetting;
if (column.IsString || column.IsDateTime)
{
defaultValue = String.Format("'{0}'", column.DefaultSetting);
}
sql.AppendFormat(UPDATE_DEFAULTS, tableName, column.Name, defaultValue);
}
return sql.ToString();
}
示例9: AppendColumnSpecificationWithoutName
protected void AppendColumnSpecificationWithoutName(StringBuilder sql, IColumn column, bool scriptDefault = true) {
sql.Append(this.TypeName(column.DbType));
if (column.DbType.TypeTakesLength()) {
sql.Append("(");
if (column.MaxLength) {
sql.Append("max");
}
else {
sql.Append(column.Length);
}
sql.Append(")");
}
if (column.DbType.TypeTakesPrecisionAndScale()) {
this.AppendPrecisionAndScale(sql, column.Precision, column.Scale);
}
sql.Append(column.IsNullable ? " null" : " not null");
if (scriptDefault && !string.IsNullOrEmpty(column.Default) && !column.IsPrimaryKey && !column.IsAutoGenerated) {
this.AppendDefault(sql, column);
}
if (column.IsAutoGenerated) {
this.AppendAutoGenerateModifier(sql, column);
}
if (column.IsPrimaryKey) {
sql.Append(" primary key");
}
}
示例10: RenderInput
protected override string RenderInput(IColumn column)
{
StringBuilder sb = new StringBuilder(string.Format(@"@{{ var radioDefaultValue_{0} = @""{1}"";}}", column.Name, column.DefaultValue.EscapeQuote()));
if (!string.IsNullOrEmpty(column.SelectionFolder))
{
sb.AppendFormat(@"
@{{
var textFolder_{0} = new TextFolder(Repository.Current, ""{1}"");
var query_{0} = textFolder_{0}.CreateQuery().DefaultOrder();
}}
@foreach (var item in query_{0})
{{
<input id=""{0}"" name=""{0}"" type=""radio"" value=""@item.UUID"" @((Model.{0} != null && Model.{0}.ToString().ToLower() == @item.UUID.ToLower()) || (Model.{0} == null && radioDefaultValue_{0}.ToLower() == @item.UUID.ToLower()) ? ""checked"" : """")/><label for=""{0}"">@item.GetSummary()</label>
}}
", column.Name, column.SelectionFolder);
}
else
{
if (column.SelectionItems != null)
{
var index = 0;
foreach (var item in column.SelectionItems)
{
var id = column.Name + "_" + index.ToString();
index++;
sb.AppendFormat(@"
<input id=""{0}"" name=""{1}"" type=""radio"" value=""@(@""{2}"")"" @((Model.{1} != null && Model.{1}.ToString().ToLower() == @""{2}"".ToLower()) || (Model.{1} == null && radioDefaultValue_{1}.ToLower() == @""{2}"".ToLower()) ? ""checked"" : """")/><label for=""{0}"">{3}</label>"
, id, column.Name, item.Value.EscapeQuote(), item.Text);
}
}
}
return sb.ToString();
}
示例11: ModifyColumn
public override string ModifyColumn(IColumn fromColumn, IColumn toColumn) {
var sql = new StringBuilder("alter table ");
this.AppendQuotedTableName(sql, toColumn.Map);
sql.Append(" modify column ");
this.AppendColumnSpecification(sql, toColumn);
return sql.ToString();
}
示例12: RenderColumnHeader
void RenderColumnHeader(IColumn c, Painter p, Node n)
{
p.SetPosition(c.Left);
if (c.Left > 0)
p.DrawSeparatorLine(Pens.Black);
p.Pad(4);
p.DrawString(c.Name, Font, Brushes.Black, 3, c.Left + c.Width);
}
示例13: DateTimeProperty
public DateTimeProperty(string displayname, IColumn column)
{
Type = FilterType.DateTime;
// DisplayPrefix = "txt";
DisplayName = ResourceManager.GetString(displayname);
Column = column;
Operators = new[] { OperatorType.IsEqual, OperatorType.IsLarger, OperatorType.IsLargerOrEqual, OperatorType.IsSmaller, OperatorType.IsSmallerOrEqual };
}
示例14: Render
public override string Render(ISchema schema, IColumn column)
{
string html = string.Format(CheckBoxTemplate, column.Name,
(string.IsNullOrEmpty(column.Label) ? column.Name : column.Label).RazorHtmlEncode(), RenderInput(column),
FormHelper.Tooltip(column.Tooltip));
return html;
}
示例15: AppendAutoGenerateModifier
protected override void AppendAutoGenerateModifier(StringBuilder sql, IColumn column) {
if (column.Type == typeof(Guid)) {
sql.Append(" NEWSEQUENTIALID()");
}
else {
sql.Append(" identity(1,1)");
}
}