Пример #1
0
        private static string GetValue(EnumerableRowCollection <DataRow> fieldRows, string fieldCode, string value)
        {
            if (Config.Constant.IsOracleDb)
            {
                var field = fieldRows.SingleOrDefault(c => c.Field <string>("FIELDCODE").ToUpper() == fieldCode.ToUpper());
                if (string.IsNullOrEmpty(value))
                {
                    if (field["TYPE"].ToString() != "NVARCHAR2" && field["NULLABLE"].ToString() == "1")
                    {
                        value = "NULL";
                    }
                    else
                    {
                        value = "''";
                    }
                }
                else
                {
                    if (field["TYPE"].ToString().Contains("TIMESTAMP"))
                    {
                        value = string.Format("to_date('{0}','yyyy-MM-dd hh24:mi:ss')", DateTime.Parse(value));
                    }
                    else
                    {
                        value = "N'" + value + "'";
                    }
                }

                return(value);
            }
            else
            {
                var field = fieldRows.SingleOrDefault(c => c.Field <string>("FieldCode") == fieldCode);
                if (string.IsNullOrEmpty(value))
                {
                    if (field["Type"].ToString() != "nvarchar" && field["Nullable"].ToString() == "1")
                    {
                        value = "NULL";
                    }
                    else
                    {
                        value = "''";
                    }
                }
                else
                {
                    if (field["Type"].ToString() == "varbinary" && field["Length"].ToString() == "500")
                    {
                        value = string.Format("EncryptByKey(KEY_GUID('SymmetricByCert'), N'{0}')", value);
                    }
                    else
                    {
                        value = "N'" + value + "'";
                    }
                }
                return(value);
            }
        }
Пример #2
0
        private static string GetValue(EnumerableRowCollection <DataRow> fieldRows, string fieldCode, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                var field = fieldRows.SingleOrDefault(c => c.Field <string>("FieldCode") == fieldCode);
                if (field["Type"].ToString() != "nvarchar" && field["Nullable"].ToString() == "1")
                {
                    value = "NULL";
                }
                else
                {
                    value = "''";
                }
            }
            else
            {
                value = "'" + value + "'";
            }

            return(value);
        }