本文整理汇总了C#中IType.SqlTypes方法的典型用法代码示例。如果您正苦于以下问题:C# IType.SqlTypes方法的具体用法?C# IType.SqlTypes怎么用?C# IType.SqlTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.SqlTypes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnType
public override IType ReturnType(IType columnType, IMapping mapping)
{
if (columnType == null)
{
throw new ArgumentNullException("columnType");
}
SqlType[] sqlTypes;
try
{
sqlTypes = columnType.SqlTypes(mapping);
}
catch (MappingException me)
{
throw new QueryException(me);
}
if (sqlTypes.Length != 1)
{
throw new QueryException("multi-column type can not be in avg()");
}
SqlType sqlType = sqlTypes[0];
if (sqlType.DbType == DbType.Int16 || sqlType.DbType == DbType.Int32 || sqlType.DbType == DbType.Int64)
{
return NHibernateUtil.Single;
}
else
{
return columnType;
}
}
示例2: AddColumn
/// <summary>
/// Adds the Property's columns to the INSERT sql
/// </summary>
/// <param name="columnName">The column name for the Property</param>
/// <param name="propertyType">The IType of the property.</param>
/// <returns>The SqlInsertBuilder.</returns>
/// <remarks>The column will be associated with a parameter.</remarks>
public virtual SqlInsertBuilder AddColumn(string columnName, IType propertyType)
{
SqlType[] sqlTypes = propertyType.SqlTypes(factory);
if (sqlTypes.Length > 1)
throw new AssertionFailure("Adding one column for a composed IType.");
columns[columnName] = sqlTypes[0];
return this;
}
示例3: ReturnType
//H3.2 behavior
public override IType ReturnType(IType columnType, IMapping mapping)
{
if (columnType == null)
{
throw new ArgumentNullException("columnType");
}
SqlType[] sqlTypes;
try
{
sqlTypes = columnType.SqlTypes(mapping);
}
catch (MappingException me)
{
throw new QueryException(me);
}
if (sqlTypes.Length != 1)
{
throw new QueryException("multi-column type can not be in sum()");
}
SqlType sqlType = sqlTypes[0];
// TODO: (H3.2 for nullable types) First allow the actual type to control the return value. (the actual underlying sqltype could actually be different)
// finally use the sqltype if == on Hibernate types did not find a match.
switch (sqlType.DbType)
{
case DbType.Single:
case DbType.Double:
return NHibernateUtil.Double;
case DbType.SByte:
case DbType.Int16:
case DbType.Int32:
case DbType.Int64:
return NHibernateUtil.Int64;
case DbType.Byte:
case DbType.UInt16:
case DbType.UInt32:
case DbType.UInt64:
return NHibernateUtil.UInt64;
default:
return columnType;
}
}
示例4: ReturnType
public override IType ReturnType(IType columnType, IMapping mapping)
{
if (columnType == null)
{
throw new ArgumentNullException("columnType");
}
SqlType[] sqlTypes;
try
{
sqlTypes = columnType.SqlTypes(mapping);
}
catch (MappingException me)
{
throw new QueryException(me);
}
if (sqlTypes.Length != 1)
{
throw new QueryException("multi-column type can not be in avg()");
}
return NHibernateUtil.Double;
}
示例5: Exists
private bool Exists(object key, object indexOrElement, IType indexOrElementType, SqlString sql,
ISessionImplementor session)
{
using(new SessionIdLoggingContext(session.SessionId))
try
{
List<SqlType> sqlTl = new List<SqlType>(KeyType.SqlTypes(factory));
sqlTl.AddRange(indexOrElementType.SqlTypes(factory));
IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sql, sqlTl.ToArray());
IDataReader rs = null;
try
{
KeyType.NullSafeSet(st, key, 0, session);
indexOrElementType.NullSafeSet(st, indexOrElement, keyColumnNames.Length, session);
rs = session.Batcher.ExecuteReader(st);
try
{
return rs.Read();
}
finally
{
rs.Close();
}
}
catch (TransientObjectException)
{
return false;
}
finally
{
session.Batcher.CloseCommand(st, rs);
}
}
catch (DbException sqle)
{
throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, sqle,
"could not check row existence: " + MessageHelper.InfoString(this, key, Factory),
GenerateSelectSizeString(session));
}
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:40,代码来源:AbstractCollectionPersister.cs
示例6: AreCompatible
/// <summary>
/// Determine whether the two types are "assignment compatible".
/// </summary>
/// <param name="target">The type defined in the into-clause.</param>
/// <param name="source">The type defined in the select clause.</param>
/// <returns>True if they are assignment compatible.</returns>
private bool AreCompatible(IType target, IType source)
{
if (target.Equals(source))
{
// if the types report logical equivalence, return true...
return true;
}
// otherwise, perform a "deep equivalence" check...
if (!target.ReturnedClass.IsAssignableFrom(source.ReturnedClass))
{
return false;
}
SqlType[] targetDatatypes = target.SqlTypes(SessionFactoryHelper.Factory);
SqlType[] sourceDatatypes = source.SqlTypes(SessionFactoryHelper.Factory);
if (targetDatatypes.Length != sourceDatatypes.Length)
{
return false;
}
for (int i = 0; i < targetDatatypes.Length; i++)
{
if (!AreSqlTypesCompatible(targetDatatypes[i], sourceDatatypes[i]))
{
return false;
}
}
return true;
}
示例7: AddWhereFragment
/// <summary>
/// Adds the columns for the Type to the WhereFragment
/// </summary>
/// <param name="columnNames">The names of the columns to add.</param>
/// <param name="type">The IType of the property.</param>
/// <param name="op">The operator to put between the column name and value.</param>
/// <returns>The SqlDeleteBuilder</returns>
public SqlDeleteBuilder AddWhereFragment(string[] columnNames, IType type, string op)
{
whereStrings.Add(ToWhereString(columnNames, op));
parameterTypes.AddRange(type.SqlTypes(Mapping));
return this;
}
示例8: SetIdentityColumn
/// <summary>
/// Sets the IdentityColumn for the <c>DELETE</c> sql to use.
/// </summary>
/// <param name="columnNames">An array of the column names for the Property</param>
/// <param name="identityType">The IType of the Identity Property.</param>
/// <returns>The SqlDeleteBuilder.</returns>
public SqlDeleteBuilder SetIdentityColumn(string[] columnNames, IType identityType)
{
whereStrings.Add(ToWhereString(columnNames));
parameterTypes.AddRange(identityType.SqlTypes(Mapping));
return this;
}
示例9: AddColumns
public SqlInsertBuilder AddColumns(string[] columnNames, bool[] insertable, IType propertyType)
{
SqlType[] sqlTypes = propertyType.SqlTypes(factory);
for (int i = 0; i < columnNames.Length; i++)
{
if (insertable == null || insertable[i])
{
if (i >= sqlTypes.Length)
throw new AssertionFailure("Different columns and it's IType.");
columns[columnNames[i]] = sqlTypes[i];
}
}
return this;
}
示例10: AddWhereFragment
/// <summary>
/// Adds the columns for the Type to the WhereFragment
/// </summary>
/// <param name="columnNames">The names of the columns to add.</param>
/// <param name="type">The IType of the property.</param>
/// <param name="op">The operator to put between the column name and value.</param>
/// <returns>The SqlUpdateBuilder</returns>
public SqlUpdateBuilder AddWhereFragment(string[] columnNames, IType type, string op)
{
if (columnNames.Length > 0)
{
// Don't add empty conditions - we get extra ANDs
whereStrings.Add(ToWhereString(columnNames, op));
whereParameterTypes.AddRange(type.SqlTypes(Mapping));
}
return this;
}
示例11: SetJoin
public SqlUpdateBuilder SetJoin(string joinTableName, string[] keyColumnNames, IType identityType, string[] lhsColumnNames, string[] rhsColumnNames)
{
var sqlBuilder = new SqlStringBuilder()
.Add("EXISTS (SELECT * FROM ")
.Add(joinTableName)
.Add(" WHERE ")
.Add(ToWhereString(joinTableName, keyColumnNames));
for (int columnIndex = 0; columnIndex < lhsColumnNames.Length; columnIndex++)
{
sqlBuilder.Add(" AND ")
.Add(tableName)
.Add(StringHelper.Dot.ToString())
.Add(lhsColumnNames[columnIndex])
.Add("=")
.Add(joinTableName)
.Add(StringHelper.Dot.ToString())
.Add(rhsColumnNames[columnIndex]);
}
sqlBuilder.Add(")");
whereStrings.Add(sqlBuilder.ToSqlString());
whereParameterTypes.AddRange(identityType.SqlTypes(Mapping));
return this;
}
示例12: AddColumns
public SqlInsertBuilder AddColumns(string[] columnNames, bool[] insertable, IType propertyType)
{
SqlType[] sqlTypes = propertyType.SqlTypes(factory);
for (int i = 0; i < columnNames.Length; i++)
{
if (insertable == null || insertable[i])
{
this.columnNames.Add(columnNames[i]);
this.columnValues.Add(Parameter.Placeholder);
this.parameterTypes.Add(sqlTypes[i]);
}
}
return this;
}
示例13: GenerateParameters
/// <summary>
/// Generates an Array of Parameters for the columns that make up the IType
/// </summary>
/// <param name="factory">The SessionFactory to use to get the DbTypes.</param>
/// <param name="tableAlias">The Alias for the Table.</param>
/// <param name="columnNames">The names of the Columns that compose the IType</param>
/// <param name="type">The IType to turn into Parameters</param>
/// <returns>An Array of <see cref="Parameter"/> objects</returns>
public static Parameter[ ] GenerateParameters( IMapping factory, string tableAlias, string[ ] columnNames, IType type )
{
SqlType[ ] sqlTypes = type.SqlTypes( factory );
Parameter[ ] parameters = new Parameter[sqlTypes.Length];
for( int i = 0; i < sqlTypes.Length; i++ )
{
if( sqlTypes[ i ].LengthDefined )
{
ParameterLength param = new ParameterLength( columnNames[i], tableAlias, sqlTypes[i] );
parameters[ i ] = param;
}
else if( sqlTypes[ i ].PrecisionDefined )
{
ParameterPrecisionScale param = new ParameterPrecisionScale( columnNames[i], tableAlias, sqlTypes[i] );
parameters[ i ] = param;
}
else
{
parameters[ i ] = new Parameter( columnNames[i], tableAlias, sqlTypes[i] );
}
}
return parameters;
}
示例14: MakeDataProperty
/// <summary>
/// Make data property metadata for the entity
/// </summary>
/// <param name="propName">name of the property on the server</param>
/// <param name="type">data type of the property, e.g. Int32</param>
/// <param name="isNullable">whether the property is nullable in the database</param>
/// <param name="isKey">true if this property is part of the key for the entity</param>
/// <param name="isVersion">true if this property contains the version of the entity (for a concurrency strategy)</param>
/// <returns></returns>
private Dictionary<string, object> MakeDataProperty(string propName, IType type, bool isNullable, bool isKey, bool isVersion)
{
string newType;
var typeName = (BreezeTypeMap.TryGetValue(type.Name, out newType)) ? newType : type.Name;
var dmap = new Dictionary<string, object>();
dmap.Add("nameOnServer", propName);
dmap.Add("dataType", typeName);
dmap.Add("isNullable", isNullable);
var sqlTypes = type.SqlTypes((ISessionFactoryImplementor)this._sessionFactory);
var sqlType = sqlTypes[0];
//if (col != null && col.DefaultValue != null)
//{
// dmap.Add("defaultValue", col.DefaultValue);
//}
if (isKey)
{
dmap.Add("isPartOfKey", true);
}
if (isVersion)
{
dmap.Add("concurrencyMode", "Fixed");
}
var validators = new List<Dictionary<string, string>>();
if (!isNullable)
{
validators.Add(new Dictionary<string, string>() {
{"name", "required" },
});
}
if (sqlType.LengthDefined)
{
dmap.Add("maxLength", sqlType.Length);
validators.Add(new Dictionary<string, string>() {
{"maxLength", sqlType.Length.ToString() },
{"name", "maxLength" }
});
}
string validationType;
if (ValidationTypeMap.TryGetValue(typeName, out validationType))
{
validators.Add(new Dictionary<string, string>() {
{"name", validationType },
});
}
if (validators.Any())
dmap.Add("validators", validators);
return dmap;
}
示例15: AddColumns
public SqlUpdateBuilder AddColumns(string[] columnNames, bool[] updateable, IType propertyType)
{
SqlType[] sqlTypes = propertyType.SqlTypes(Mapping);
for (int i = 0; i < columnNames.Length; i++)
{
if (updateable == null || updateable[i])
{
this.columnNames.Add(columnNames[i]);
this.columnValues.Add(Parameter.Placeholder);
this.columnValuesParameterTypes.Add(sqlTypes[i]);
}
}
return this;
}