本文整理汇总了C#中IBatisNet.DataMapper.Configuration.ResultMapping.ResultProperty类的典型用法代码示例。如果您正苦于以下问题:C# ResultProperty类的具体用法?C# ResultProperty怎么用?C# ResultProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResultProperty类属于IBatisNet.DataMapper.Configuration.ResultMapping命名空间,在下文中一共展示了ResultProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectStrategy
/// <summary>
/// Initializes a new instance of the <see cref="SelectStrategy"/> class.
/// </summary>
/// <param name="mapping">The mapping.</param>
/// <param name="selectArrayStrategy">The select array strategy.</param>
/// <param name="selectGenericListStrategy">The select generic list strategy.</param>
/// <param name="selectListStrategy">The select list strategy.</param>
/// <param name="selectObjectStrategy">The select object strategy.</param>
public SelectStrategy(ResultProperty mapping,
IArgumentStrategy selectArrayStrategy,
IArgumentStrategy selectGenericListStrategy,
IArgumentStrategy selectListStrategy,
IArgumentStrategy selectObjectStrategy)
{
// Collection object or .NET object
if (mapping.MemberType.BaseType == typeof(Array))
{
_selectStrategy = selectArrayStrategy;
}
else if (mapping.MemberType.IsGenericType &&
typeof(IList<>).IsAssignableFrom(mapping.MemberType.GetGenericTypeDefinition()))
{
_selectStrategy = selectGenericListStrategy;
}
// Check if the object to Map implement 'IList' or is IList type
// If yes the ResultProperty is map to a IList object
else if (typeof(IList).IsAssignableFrom(mapping.MemberType))
{
_selectStrategy = selectListStrategy;
}
else // The ResultProperty is map to a .Net object
{
_selectStrategy = selectObjectStrategy;
}
}
示例2: GetValue
/// <summary>
/// Gets the value of an argument constructor.
/// </summary>
/// <param name="request">The current <see cref="RequestScope"/>.</param>
/// <param name="mapping">The <see cref="ResultProperty"/> with the argument infos.</param>
/// <param name="reader">The current <see cref="IDataReader"/>.</param>
/// <param name="keys">The keys</param>
/// <returns>The paremeter value.</returns>
public object GetValue(RequestScope request, ResultProperty mapping,
ref IDataReader reader, object keys)
{
if (mapping.TypeHandler == null ||
mapping.TypeHandler is UnknownTypeHandler) // Find the TypeHandler
{
lock(mapping)
{
if (mapping.TypeHandler == null || mapping.TypeHandler is UnknownTypeHandler)
{
int columnIndex = 0;
if (mapping.ColumnIndex == ResultProperty.UNKNOWN_COLUMN_INDEX)
{
columnIndex = reader.GetOrdinal(mapping.ColumnName);
}
else
{
columnIndex = mapping.ColumnIndex;
}
Type systemType =((IDataRecord)reader).GetFieldType(columnIndex);
mapping.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(systemType);
}
}
}
object dataBaseValue = mapping.GetDataBaseValue( reader );
request.IsRowDataFound = request.IsRowDataFound || (dataBaseValue != null);
return dataBaseValue;
}
示例3: Process
/// <summary>
/// Processes the specified <see cref="IDataReader"/>
/// when no resultClass or resultMap attribute are specified.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="reader">The reader.</param>
/// <param name="resultObject">The result object.</param>
public object Process(RequestScope request, ref IDataReader reader, object resultObject)
{
object outObject = resultObject;
if (reader.FieldCount == 1)
{
ResultProperty property = new ResultProperty();
property.PropertyName = "value";
property.ColumnIndex = 0;
property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(0));
outObject = property.GetDataBaseValue(reader);
}
else if (reader.FieldCount > 1)
{
object[] newOutObject = new object[reader.FieldCount];
int count = reader.FieldCount;
for (int i = 0; i < count; i++)
{
ResultProperty property = new ResultProperty();
property.PropertyName = "value";
property.ColumnIndex = i;
property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(i));
newOutObject[i] = property.GetDataBaseValue(reader);
}
outObject = newOutObject;
}
else
{
// do nothing if 0 fields
}
return outObject;
}
示例4: Set
///<summary>
/// Sets value of the specified <see cref="ResultProperty"/> on the target object
/// when a 'select' attribute exists and fills an <see cref="IList"/> property
/// on the <see cref="ResultProperty"/> are empties.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="resultMap">The result map.</param>
/// <param name="mapping">The ResultProperty.</param>
/// <param name="target">The target.</param>
/// <param name="reader">The current <see cref="IDataReader"/></param>
/// <param name="keys">The keys</param>
public void Set(RequestScope request, IResultMap resultMap,
ResultProperty mapping, ref object target, IDataReader reader, object keys)
{
// Get the select statement
IMappedStatement selectStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);
PostBindind postSelect = new PostBindind();
postSelect.Statement = selectStatement;
postSelect.Keys = keys;
postSelect.Target = target;
postSelect.ResultProperty = mapping;
if (mapping.IsLazyLoad)
{
object values = mapping.LazyFactory.CreateProxy(selectStatement, keys, target, mapping.SetAccessor);
mapping.SetAccessor.Set(target, values);
}
else
{
if (mapping.SetAccessor.MemberType == typeof(IList))
{
postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForIList;
}
else
{
postSelect.Method = PostBindind.ExecuteMethod.ExecuteQueryForStrongTypedIList;
}
request.QueueSelect.Enqueue(postSelect);
}
}
示例5: Process
/// <summary>
/// Processes the specified <see cref="IDataReader"/>
/// when a ResultClass is specified on the statement and
/// the ResultClass is a SimpleType.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="reader">The reader.</param>
/// <param name="resultObject">The result object.</param>
public object Process(RequestScope request, ref IDataReader reader, object resultObject)
{
object outObject = resultObject;
AutoResultMap resultMap = request.CurrentResultMap as AutoResultMap;
if (outObject == null)
{
outObject = resultMap.CreateInstanceOfResultClass();
}
if (!resultMap.IsInitalized)
{
lock(resultMap)
{
if (!resultMap.IsInitalized)
{
// Create a ResultProperty
ResultProperty property = new ResultProperty();
property.PropertyName = "value";
property.ColumnIndex = 0;
property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(outObject.GetType());
property.PropertyStrategy = PropertyStrategyFactory.Get(property);
resultMap.Properties.Add(property);
resultMap.DataExchange = request.DataExchangeFactory.GetDataExchangeForClass(typeof(int));// set the PrimitiveDataExchange
resultMap.IsInitalized = true;
}
}
}
resultMap.Properties[0].PropertyStrategy.Set(request, resultMap, resultMap.Properties[0], ref outObject, reader, null);
return outObject;
}
示例6: Process
/// <summary>
/// Processes the specified <see cref="IDataReader"/>
/// when a 'resultClass' attribute is specified on the statement and
/// the 'resultClass' attribute is a <see cref="IDictionary"/>.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="reader">The reader.</param>
/// <param name="resultObject">The result object.</param>
public object Process(RequestScope request, ref IDataReader reader, object resultObject)
{
object outObject = resultObject;
AutoResultMap resultMap = request.CurrentResultMap as AutoResultMap;
if (outObject == null)
{
outObject = resultMap.CreateInstanceOfResultClass();
}
int count = reader.FieldCount;
IDictionary dictionary = (IDictionary) outObject;
for (int i = 0; i < count; i++)
{
ResultProperty property = new ResultProperty();
property.PropertyName = "value";
property.ColumnIndex = i;
property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(i));
dictionary.Add(
reader.GetName(i),
property.GetDataBaseValue(reader));
}
return outObject;
}
示例7: GetValue
/// <summary>
/// Gets the value of an argument constructor.
/// </summary>
/// <param name="request">The current <see cref="RequestScope"/>.</param>
/// <param name="mapping">The <see cref="ResultProperty"/> with the argument infos.</param>
/// <param name="reader">The current <see cref="IDataReader"/>.</param>
/// <param name="keys">The keys</param>
/// <returns>The paremeter value.</returns>
public object GetValue(RequestScope request, ResultProperty mapping,
ref IDataReader reader, object keys)
{
// Get the select statement
IMappedStatement selectStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);
reader = DataReaderTransformer.Transform(reader, request.Session.DataSource.DbProvider);
return selectStatement.ExecuteQueryForObject(request.Session, keys);
}
示例8: GetValueByIndex
/// <summary>
/// Gets a column value by the index
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
{
if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
{
return DBNull.Value;
}
else
{
return new UInt64?(Convert.ToUInt64(dataReader.GetValue(mapping.ColumnIndex)));
}
}
示例9: GetValueByIndex
/// <summary>
/// Gets a column value by the index
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
{
if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
{
return DBNull.Value;
}
else
{
return Enum.Parse(mapping.MemberType, dataReader.GetValue(mapping.ColumnIndex).ToString());
}
}
示例10: GetValueByIndex
/// <summary>
/// Gets a column value by the index
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
{
if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
{
return DBNull.Value;
}
else
{
return new DateTime?(dataReader.GetDateTime(mapping.ColumnIndex));
}
}
示例11: GetValueByIndex
/// <summary>
/// Gets a column value by the index
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
{
if (dataReader.IsDBNull(mapping.ColumnIndex) || dataReader.GetBytes(mapping.ColumnIndex, 0, null, 0, 0) == 0)
{
return DBNull.Value;
}
else
{
return GetValueByIndex(mapping.ColumnIndex, dataReader);
}
}
示例12: GetValueByIndex
/// <summary>
/// Gets a column value by the index
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
{
if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
{
return System.DBNull.Value;
}
else
{
return dataReader.GetValue(mapping.ColumnIndex);
}
}
示例13: GetValueByIndex
/// <summary>
/// Gets a column value by the index
/// </summary>
/// <param name="mapping"></param>
/// <param name="dataReader"></param>
/// <returns></returns>
public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader)
{
if (dataReader.IsDBNull(mapping.ColumnIndex) == true)
{
return DBNull.Value;
}
else
{
// Don't used dataReader.GetInt32 to fix oracle who alwray return decimal type
return Convert.ToUInt16(dataReader.GetValue(mapping.ColumnIndex));
}
}
示例14: Deserialize
/// <summary>
/// Deserialize a ResultProperty object
/// </summary>
/// <param name="node"></param>
/// <param name="configScope"></param>
/// <returns></returns>
public static ResultProperty Deserialize(XmlNode node, ConfigurationScope configScope)
{
ResultProperty resultProperty = new ResultProperty();
NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties);
resultProperty.CLRType = NodeUtils.GetStringAttribute(prop, "type");
resultProperty.CallBackName = NodeUtils.GetStringAttribute(prop, "typeHandler");
resultProperty.ColumnIndex = NodeUtils.GetIntAttribute( prop, "columnIndex", ResultProperty.UNKNOWN_COLUMN_INDEX );
resultProperty.ColumnName = NodeUtils.GetStringAttribute(prop, "column");
resultProperty.DbType = NodeUtils.GetStringAttribute(prop, "dbType");
resultProperty.IsLazyLoad = NodeUtils.GetBooleanAttribute( prop, "lazyLoad", false);
resultProperty.NestedResultMapName = NodeUtils.GetStringAttribute(prop, "resultMapping");
resultProperty.NullValue = prop["nullValue"];
resultProperty.PropertyName = NodeUtils.GetStringAttribute(prop, "property");
resultProperty.Select = NodeUtils.GetStringAttribute(prop, "select");
return resultProperty;
}
示例15: GetValue
/// <summary>
/// Gets the value of an argument constructor.
/// </summary>
/// <param name="request">The current <see cref="RequestScope"/>.</param>
/// <param name="mapping">The <see cref="ResultProperty"/> with the argument infos.</param>
/// <param name="reader">The current <see cref="IDataReader"/>.</param>
/// <param name="keys">The keys</param>
/// <returns>The paremeter value.</returns>
public object GetValue(RequestScope request, ResultProperty mapping,
ref IDataReader reader, object keys)
{
// Get the select statement
IMappedStatement selectStatement = request.MappedStatement.SqlMap.GetMappedStatement(mapping.Select);
reader = DataReaderTransformer.Transform(reader, request.Session.DataSource.DbProvider);
IList values = selectStatement.ExecuteQueryForList(request.Session, keys);
Type elementType = mapping.MemberType.GetElementType();
Array array = Array.CreateInstance(elementType, values.Count);
int count = values.Count;
for(int i=0;i<count;i++)
{
array.SetValue(values[i],i);
}
return array;
}