public string GetDataTypeString(DbBindColumn col) { string nativeType = col.NativeType.ToLower(); StringBuilder sb = new StringBuilder(); if (nativeType == "varchar" || nativeType == "nvarchar" || nativeType == "char" || nativeType == "nchar" || nativeType == "binary" || nativeType == "varbinary") { sb.Append(col.NativeType); sb.Append("("); sb.Append(col.Column.ColumnLength >= 0 ? col.Column.ColumnLength.ToString() : "MAX"); sb.Append(")"); } else if (nativeType == "decimal" || nativeType == "numeric") { sb.Append(col.NativeType); sb.Append("("); sb.Append(col.Column.ColumnLength.ToString()); sb.Append(", "); sb.Append(col.Column.ColumnScale.ToString()); sb.Append(")"); } else { sb.Append(col.NativeType); } return(sb.ToString()); }
protected DbType GetDbType(DbBindColumn prop) { if (prop.NativeType == "real") { return(DbType.Single); } return(prop.DataType); }
public static DbType GetDbType(this DbBindColumn prop) { if (prop.NativeType == "real") { return(DbType.Single); } return(prop.DataType); }
public string GetWhereClause(CslaObjectInfo info, Criteria crit, bool onlyChildObjects) { CslaObjectInfo originalInfo = info; CslaObjectInfo parentInfo = FindParent(info); if (parentInfo != null) { CslaObjectInfo temp = parentInfo; while (temp != null) { temp = FindParent(temp); if (temp != null) { parentInfo = temp; } } info = parentInfo; } StringBuilder sb = new StringBuilder(); bool first = true; foreach (CriteriaProperty parm in crit.Properties) { DbBindColumn dbc = parm.DbBindColumn; if (dbc == null || dbc.Column == null) { ValueProperty prop = GetValuePropertyByName(info, parm.Name); if (prop != null) { dbc = prop.DbBindColumn; } } if (dbc != null && dbc.Column != null) { if (!first) { sb.Append(" AND" + Environment.NewLine); } else { sb.Append(Indent(2) + "WHERE" + Environment.NewLine); first = false; } sb.Append(Indent(3) + " " + GetAliasedFieldString(dbc)); sb.Append(" = @"); sb.Append(parm.ParameterName); } } sb.Append(SoftDeleteWhereClause(info, originalInfo, crit, onlyChildObjects, first)); return(sb.ToString()); }
public static void SetDbBindColumn(TreeNode node, IColumnInfo p, DbBindColumn dbc) { //TreeNode node = TreeViewSchema.SelectedNode; IResultSet rs = (IResultSet)node.Tag; IStoredProcedureInfo sp = null; if (node.Parent.Tag != null) { sp = (IStoredProcedureInfo)node.Parent.Tag; } IDataBaseObject obj = null; if (sp != null) { obj = sp; dbc.SpResultIndex = sp.ResultSets.IndexOf(rs); } else { obj = (IDataBaseObject)rs; } switch (rs.Type) { case ResultType.Table: dbc.ColumnOriginType = ColumnOriginType.Table; break; case ResultType.View: dbc.ColumnOriginType = ColumnOriginType.View; break; case ResultType.StoredProcedure: dbc.ColumnOriginType = ColumnOriginType.StoredProcedure; break; } //dbc.ColumnOriginType= dbc.CatalogName = obj.ObjectCatalog; dbc.SchemaName = obj.ObjectSchema; dbc.ObjectName = obj.ObjectName; dbc.ColumnName = p.ColumnName; dbc.LoadColumn(GeneratorController.Catalog); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (_editorService != null) { if (context.Instance != null) { // CR modifying to accomodate PropertyBag Type instanceType = null; object objinfo = null; ContextHelper.GetContextInstanceObject(context, ref objinfo, ref instanceType); var obj = (IBoundProperty)objinfo; using (var frm = new DbBindColumnEditorForm()) { frm.ColumnInfo = obj.DbBindColumn.Column; if (_editorService.ShowDialog(frm) == DialogResult.Cancel) { return(value); } var selected = frm.SelectedNode; IColumnInfo newCol = null; if (selected != null) { newCol = selected.Tag as IColumnInfo; } if (frm.NoneSelected) { obj.DbBindColumn = new DbBindColumn(); } else if (newCol != null) { var newDbc = new DbBindColumn(); Controls.DbSchemaPanel.SetDbBindColumn(selected.Parent, newCol, newDbc); obj.DbBindColumn = newDbc; } } } } return(value); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(String)) { if (value is DbBindColumn) { DbBindColumn col = (DbBindColumn)value; if (col.ColumnOriginType == ColumnOriginType.StoredProcedure) { return(String.Format("{0} ({1}:{2})", col.ColumnName, col.ObjectName, col.SpResultIndex)); } else { return(String.Format("{0} ({1})", col.ColumnName, col.ObjectName)); } } } return(base.ConvertTo(context, culture, value, destinationType)); }
private void SetDbBindColumn(IColumnInfo p, DbBindColumn dbc) { SetDbBindColumn(TreeViewSchema.SelectedNode, p, dbc); }
public string GetSearchWhereClause(CslaObjectInfo info, CslaObjectInfo originalInfo, Criteria crit) { StringBuilder sb = new StringBuilder(); bool first = true; foreach (CriteriaProperty parm in crit.Properties) { DbBindColumn dbc = parm.DbBindColumn; if (dbc == null) { ValueProperty prop = GetValuePropertyByName(info, parm.Name); dbc = prop.DbBindColumn; } if (dbc != null) { if (!first) { sb.Append(" AND" + Environment.NewLine); } else { sb.Append(Indent(2) + "WHERE" + Environment.NewLine); first = false; } sb.Append(Indent(3) + " "); if (IsStringType(dbc.DataType)) { sb.Append("ISNULL("); sb.Append(GetAliasedFieldString(dbc)); sb.Append(", '')"); // ValueProperty prop = GetValuePropertyByName(info, parm.Name); // if (prop.DbBindColumn.DataType.ToString() == "StringFixedLength") if (dbc.DataType.ToString() == "StringFixedLength") { sb.Append(" LIKE RTRIM(@"); sb.Append(parm.ParameterName); sb.Append(")"); } else { sb.Append(" LIKE @"); sb.Append(parm.ParameterName); } } else { sb.Append(GetAliasedFieldString(dbc)); sb.Append(" = ISNULL(@"); sb.Append(parm.ParameterName); sb.Append(", "); sb.Append(GetAliasedFieldString(dbc)); sb.Append(")"); } } } sb.Append(SoftDeleteWhereClause(info, originalInfo, crit, false, first)); sb.Append(Environment.NewLine); return(sb.ToString()); }
public string GetAliasedFieldString(DbBindColumn col) { return("[" + col.ObjectName + "].[" + col.ColumnName + "]"); }
public string GetColumnString(DbBindColumn col) { return(col.ColumnName); }