Exemplo n.º 1
0
        private static string GetStringRepresentation(object o, bool allowDates, QuerySyntaxHelper escaper = null)
        {
            if (o == null || o == DBNull.Value)
            {
                return(null);
            }

            var s = o as string;

            if (s != null && allowDates)
            {
                DateTime dt;
                if (DateTime.TryParse(s, out dt))
                {
                    return(GetStringRepresentation(dt));
                }
            }

            if (o is DateTime)
            {
                return(GetStringRepresentation((DateTime)o));
            }

            var str = o.ToString();

            if (escaper != null)
            {
                str = escaper.Escape(str);
            }
            else
            {
                str = str.Replace("\"", "\"\"");
            }

            return(str);
        }