private AutoResultMap InitializeAutoResultMap(RequestScope request, ref IDataReader reader, ref object resultObject) { AutoResultMap currentResultMap = request.CurrentResultMap as AutoResultMap; if (request.Statement.AllowRemapping) { currentResultMap = currentResultMap.Clone(); ResultPropertyCollection propertys = ReaderAutoMapper.Build(request.DataExchangeFactory, reader, ref resultObject); currentResultMap.Properties.AddRange(propertys); return(currentResultMap); } if (!currentResultMap.IsInitalized) { lock (currentResultMap) { if (!currentResultMap.IsInitalized) { ResultPropertyCollection propertys2 = ReaderAutoMapper.Build(request.DataExchangeFactory, reader, ref resultObject); currentResultMap.Properties.AddRange(propertys2); currentResultMap.IsInitalized = true; } } } return(currentResultMap); }
/// <summary> /// Auto-map the reader to the result object. /// </summary> /// <param name="request">The request.</param> /// <param name="reader">The reader.</param> /// <param name="resultObject">The result object.</param> /// <returns>The AutoResultMap use to map the resultset.</returns> private AutoResultMap InitializeAutoResultMap(RequestScope request, ref IDataReader reader, ref object resultObject) { AutoResultMap resultMap = request.CurrentResultMap as AutoResultMap; bool isUseAutoMapCompatibilityMode = false; if (request.MappedStatement.SqlMap.IsUseAutoMapCompatibilityMode) { isUseAutoMapCompatibilityMode = request.MappedStatement.Statement.ForceDisabledAutoMapCompatibilityMode ? false : true; } else { isUseAutoMapCompatibilityMode = request.MappedStatement.Statement.ForceEnableAutoMapCompatibilityMode ? true : false; } if (request.Statement.AllowRemapping) { resultMap = resultMap.Clone(); ResultPropertyCollection properties = ReaderAutoMapper.Build( request.DataExchangeFactory, reader, ref resultObject, isUseAutoMapCompatibilityMode); resultMap.Properties.AddRange(properties); } else { if (!resultMap.IsInitalized) { lock (resultMap) { if (!resultMap.IsInitalized) { ResultPropertyCollection properties = ReaderAutoMapper.Build( request.DataExchangeFactory, reader, ref resultObject, isUseAutoMapCompatibilityMode); resultMap.Properties.AddRange(properties); resultMap.IsInitalized = true; } } } } return(resultMap); }
/// <summary> /// Auto-map the reader to the result object. /// </summary> /// <param name="request">The request.</param> /// <param name="reader">The reader.</param> /// <param name="resultObject">The result object.</param> /// <returns>The AutoResultMap use to map the resultset.</returns> private static AutoResultMap InitializeAutoResultMap(RequestScope request, IDataReader reader, ref object resultObject) { AutoResultMap resultMap = request.CurrentResultMap as AutoResultMap; if (request.Statement.AllowRemapping) { resultMap = resultMap.Clone(); //根据reader的字段从resultObject类中获取对应的属性类集合 ResultPropertyCollection properties = ReaderAutoMapper.Build( request.DataExchangeFactory, reader, ref resultObject); resultMap.Properties.AddRange(properties); } else { if (!resultMap.IsInitalized) { lock (resultMap) { if (!resultMap.IsInitalized) { ResultPropertyCollection properties = ReaderAutoMapper.Build( request.DataExchangeFactory, reader, ref resultObject); resultMap.Properties.AddRange(properties); resultMap.IsInitalized = true; } } } } return(resultMap); }
private AutoResultMap <T> InitializeAutoResultMap <T>(RequestScope request, ref DbDataReader reader, ref T resultObject) { var resultMap = request.CurrentResultMap as AutoResultMap <T>; if (request.Statement.AllowRemapping) { resultMap = resultMap.Clone(); ResultPropertyCollection properties = ReaderAutoMapper.Build( request.DataExchangeFactory, reader, ref resultObject); resultMap?.Properties.AddRange(properties); } else { if (resultMap != null && !resultMap.IsInitialized) { lock (resultMap) { if (!resultMap.IsInitialized) { ResultPropertyCollection properties = ReaderAutoMapper.Build( request.DataExchangeFactory, reader, ref resultObject); resultMap.Properties.AddRange(properties); resultMap.IsInitialized = true; } } } } return(resultMap); }