Ejemplo n.º 1
0
        private object DbParameterValue_Statement(object propertyValue, DatabaseEntityPropertyDef info)
        {
            if (propertyValue == null)
            {
                return(DBNull.Value);
            }

            return(info.TypeConverter == null?
                   _databaseEngine.GetDbValueStatement(propertyValue, needQuoted : false) :
                       info.TypeConverter.TypeValueToDbValue(propertyValue));
        }
Ejemplo n.º 2
0
        public static string SqlJoin(IEnumerable values, IDatabaseEngine dbEngine)
        {
            StringBuilder sb = new StringBuilder();

            foreach (object value in values)
            {
                sb.Append(dbEngine.GetDbValueStatement(value, needQuoted: true));
                sb.Append(',');
            }

            sb.Remove(sb.Length - 1, 1);

            return(sb.ToString());
        }
Ejemplo n.º 3
0
        public string SqlFormat(string sqlText, params object[] sqlParams)
        {
            List <string> escapedParams = new List <string>();

            foreach (object sqlParam in sqlParams)
            {
                if (sqlParam == null)
                {
                    escapedParams.Add("NULL");
                }
                else
                {
                    if (sqlParam is SQLInValues sqlInValues)
                    {
                        escapedParams.Add(sqlInValues.ToSqlInString(databaseEngine));
                    }
                    else
                    {
                        escapedParams.Add(databaseEngine.GetDbValueStatement(sqlParam, needQuoted: true));
                    }
                }
            }
            return(string.Format(GlobalSettings.Culture, sqlText, escapedParams.ToArray()));
        }