public int GetDataCount(ISessionImplementor session, Criteria criteria) { var sql = Map.CreateDataCountSql(session, this, criteria); var result = ExecuteScalar(session, sql.CommandText, CommandType.Text, sql.Parameters); return(result == null ? 0 : ConvertHandler.ToInt32(result)); }
public IList <Article> GetList(int[] categoryIds) { var idStr = ConvertHandler.ToString(categoryIds); var sql = string.Format("SELECT * FROM vipsoft_article WHERE category_id in ({0}) ORDER BY update_date DESC,id DESC", idStr); return(GetList(sql)); }
public Task <EncryptResponse> Handle(EncryptRequest request, CancellationToken cancellationToken) { var retVal = ConvertHandler.EncryptString(request.Data, "d123"); return(Task.FromResult(new EncryptResponse { Result = new EncryptDto { Result = JsonConvert.SerializeObject(retVal) } })); }
public CustomConverter(ConvertHandler convertHandler, ConvertHandler convertBackHandler) { if (convertHandler != null) { Convert += convertHandler; } if (convertBackHandler != null) { ConvertBack += convertBackHandler; } }
public List <T> GetPageList(int pageSize, int dataStart, out int totalItemCount, Criteria criteria, params Order[] order) { List <T> result; totalItemCount = 1 == null ? 0 : ConvertHandler.ToInt32(1); using (var session = SessionFaction.OpenSession()) { result = order != null && order.Length > 0 ? session.LoadPageList <T>(pageSize, dataStart, out totalItemCount, criteria, order[0]) : session.LoadPageList <T>(pageSize, dataStart, out totalItemCount, criteria, null); } return(result); }
/// <summary> /// Convert the specified inputObject to the output mapping type. /// </summary> /// <param name="inputObject">The inputObject must be consistent with the specified inputMappingType in ObjectMapper's Constructor.</param> /// <param name="outputObject">outputObject is an instance to set member values on instead of create a new one.</param> /// <param name="customMappingHandlers"></param> /// <returns></returns> public object ConvertObject(object inputObject, object outputObject) { Check.Require(inputObject, "inputObject"); if (outputObject == null) { if (!initType.IsAssignableFrom(typeof(DataRow))) { outputObject = Activator.CreateInstance(initType); } else { if (cachedTable != null) { outputObject = cachedTable.Clone().NewRow(); } } } if (convertHandler == null) { lock (this) { if (convertHandler == null) { convertHandler = CovnertHandlerFactory.GetConvertHandler(inputType, outputType, inputObject, outputObject, mappingNames, ignoreNames, mappingOrders, mappingSpecifiedOnly); } } } outputObject = convertHandler(inputObject, outputObject); if (outputType.IsAssignableFrom(typeof(DataRow))) { DataTable table = ((DataRow)outputObject).Table; if (cachedTable == null) { lock (this) { if (cachedTable == null) { cachedTable = table.Clone(); } } } } foreach (ICustomObjectMemberMapping customMapping in customMappings) { customMapping.Mapping(inputObject, outputObject); } return(outputObject); }
/// <summary> /// Convert the specified inputObject to the output mapping type. /// </summary> /// <param name="inputObject">The inputObject must be consistent with the specified inputMappingType in ObjectMapper's Constructor.</param> /// <param name="outputObject">outputObject is an instance to set member values on instead of create a new one.</param> /// <param name="customMappingHandlers"></param> /// <returns></returns> public object ConvertObject(object inputObject, object outputObject) { Check.Require(inputObject, "inputObject"); if (outputObject == null) { if (!initType.IsAssignableFrom(typeof(DataRow))) outputObject = Activator.CreateInstance(initType); else { if (cachedTable != null) { outputObject = cachedTable.Clone().NewRow(); } } } if (convertHandler == null) { lock (this) { if (convertHandler == null) { convertHandler = CovnertHandlerFactory.GetConvertHandler(inputType, outputType, inputObject, outputObject, mappingNames, ignoreNames, mappingOrders, mappingSpecifiedOnly); } } } try { outputObject = convertHandler(inputObject, outputObject); } catch (Exception ex) { StreamWriter sw = System.IO.File.AppendText("NBearMapping.log"); sw.WriteLine(ex.Message); sw.WriteLine(ex.StackTrace); sw.Close(); } if (outputType.IsAssignableFrom(typeof(DataRow))) { DataTable table = ((DataRow)outputObject).Table; if (cachedTable == null) { lock (this) { if (cachedTable == null) { cachedTable = table.Clone(); } } } } foreach (ICustomObjectMemberMapping customMapping in customMappings) { customMapping.Mapping(inputObject, outputObject); } return outputObject; }
public CustomConverter(ConvertHandler convertHandler) : this(convertHandler, null) { }