Ejemplo n.º 1
0
 private string BuildSql(FdoRow obj)
 {
     if (IsUsingPropertyMappings())
     {
         string[] values = new string[_mappings.Count];
         int      i      = 0;
         foreach (string target in _mappings.Keys)
         {
             string name = _mappings[target];
             if (obj[name] != null)
             {
                 if (obj.IsGeometryProperty(name))
                 {
                     values[i] = VALUE_BEGIN + ((IGeometry)obj[name]).Text + VALUE_END;
                 }
                 else if (obj[name].GetType() == typeof(string))
                 {
                     values[i] = VALUE_BEGIN + EscapeValue((string)obj[name]) + VALUE_END;
                 }
                 else if (obj[name].GetType() == typeof(DateTime))
                 {
                     values[i] = VALUE_BEGIN + ((DateTime)obj[name]).ToString(ISO8601_FMT) + VALUE_END;
                 }
                 else
                 {
                     values[i] = VALUE_BEGIN + obj[name].ToString() + VALUE_END;
                 }
             }
             else
             {
                 values[i] = GetNullValue();
             }
             i++;
         }
         return(string.Format(_sqlTpl, values));
     }
     else
     {
         string[] values = new string[_propertyTraversalList.Count];
         for (int i = 0; i < values.Length; i++)
         {
             string name = _propertyTraversalList[i];
             if (obj[name] != null)
             {
                 values[i] = VALUE_BEGIN + obj[name].ToString() + VALUE_END;
             }
             else if (obj[name].GetType() == typeof(DateTime))
             {
                 values[i] = VALUE_BEGIN + ((DateTime)obj[name]).ToString(ISO8601_FMT) + VALUE_END;
             }
             else
             {
                 values[i] = GetNullValue();
             }
         }
         return(string.Format(_sqlTpl, values));
     }
 }
Ejemplo n.º 2
0
 private string BuildSql(FdoRow obj)
 {
     if (IsUsingPropertyMappings())
     {
         string[] values = new string[_mappings.Count];
         int i = 0;
         foreach (string target in _mappings.Keys)
         {
             string name = _mappings[target];
             if (obj[name] != null)
             {
                 if (obj.IsGeometryProperty(name))
                     values[i] = VALUE_BEGIN + ((IGeometry)obj[name]).Text + VALUE_END;
                 else if (obj[name].GetType() == typeof(string))
                     values[i] = VALUE_BEGIN + EscapeValue((string)obj[name]) + VALUE_END;
                 else if (obj[name].GetType() == typeof(DateTime))
                     values[i] = VALUE_BEGIN + ((DateTime)obj[name]).ToString(ISO8601_FMT) + VALUE_END;
                 else
                     values[i] = VALUE_BEGIN + obj[name].ToString() + VALUE_END;
             }
             else
             {
                 values[i] = GetNullValue();
             }
             i++;
         }
         return string.Format(_sqlTpl, values);
     }
     else
     {
         string[] values = new string[_propertyTraversalList.Count];
         for (int i = 0; i < values.Length; i++)
         {
             string name = _propertyTraversalList[i];
             if (obj[name] != null)
                 values[i] = VALUE_BEGIN + obj[name].ToString() + VALUE_END;
             else if (obj[name].GetType() == typeof(DateTime))
                 values[i] = VALUE_BEGIN + ((DateTime)obj[name]).ToString(ISO8601_FMT) + VALUE_END;
             else
                 values[i] = GetNullValue();
         }
         return string.Format(_sqlTpl, values);
     }
 }
        private ParameterValueCollection CreateParameterValues(string prefix, FdoRow row)
        {
            ParameterValueCollection values = new ParameterValueCollection();

            if (_mappings == null || _mappings.Count == 0)
            {
                foreach (string col in row.Columns)
                {
                    //No excluded properties or property not in exclusion list
                    if (_unWritableProperties == null || _unWritableProperties.Count == 0 || !_unWritableProperties.Contains(col))
                    {
                        //Omit null values
                        if (row[col] != null && row[col] != DBNull.Value)
                        {
                            if (!row.IsGeometryProperty(col))
                            {
                                LiteralValue dv = ValueConverter.GetConvertedValue(row[col]);
                                if (dv != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + col, dv);
                                    values.Add(pv);
                                }
                            }
                            else
                            {
                                IGeometry geom = row[col] as IGeometry;
                                if (geom != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + col, new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                                    values.Add(pv);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (string col in row.Columns)
                {
                    //No excluded properties or property not in exclusion list
                    if (_unWritableProperties == null || _unWritableProperties.Count == 0 || !_unWritableProperties.Contains(col))
                    {
                        //Omit null and un-mapped values
                        if (_mappings[col] != null || row[col] != null && row[col] != DBNull.Value)
                        {
                            if (!row.IsGeometryProperty(col))
                            {
                                LiteralValue dv = ValueConverter.GetConvertedValue(row[col]);
                                if (dv != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + _mappings[col], dv);
                                    values.Add(pv);
                                }
                            }
                            else
                            {
                                IGeometry geom = row[col] as IGeometry;
                                if (geom != null)
                                {
                                    ParameterValue pv = new ParameterValue(prefix + _mappings[col], new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                                    values.Add(pv);
                                }
                            }
                        }
                    }
                }
            }
            return(values);
        }
 private ParameterValueCollection CreateParameterValues(string prefix, FdoRow row)
 {
     ParameterValueCollection values = new ParameterValueCollection();
     if (_mappings == null || _mappings.Count == 0)
     {
         foreach (string col in row.Columns)
         {
             //No excluded properties or property not in exclusion list
             if (_unWritableProperties == null || _unWritableProperties.Count == 0 || !_unWritableProperties.Contains(col))
             {
                 //Omit null values
                 if (row[col] != null && row[col] != DBNull.Value)
                 {
                     if (!row.IsGeometryProperty(col))
                     {
                         LiteralValue dv = ValueConverter.GetConvertedValue(row[col]);
                         if (dv != null)
                         {
                             ParameterValue pv = new ParameterValue(prefix + col, dv);
                             values.Add(pv);
                         }
                     }
                     else
                     {
                         IGeometry geom = row[col] as IGeometry;
                         if (geom != null)
                         {
                             ParameterValue pv = new ParameterValue(prefix + col, new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                             values.Add(pv);
                         }
                     }
                 }
             }
         }
     }
     else
     {
         foreach (string col in row.Columns)
         {
             //No excluded properties or property not in exclusion list
             if (_unWritableProperties == null || _unWritableProperties.Count == 0 || !_unWritableProperties.Contains(col))
             {
                 //Omit null and un-mapped values
                 if (_mappings[col] != null || row[col] != null && row[col] != DBNull.Value)
                 {
                     if (!row.IsGeometryProperty(col))
                     {
                         LiteralValue dv = ValueConverter.GetConvertedValue(row[col]);
                         if (dv != null)
                         {
                             ParameterValue pv = new ParameterValue(prefix + _mappings[col], dv);
                             values.Add(pv);
                         }
                     }
                     else
                     {
                         IGeometry geom = row[col] as IGeometry;
                         if (geom != null)
                         {
                             ParameterValue pv = new ParameterValue(prefix + _mappings[col], new GeometryValue(FdoGeometryFactory.Instance.GetFgf(geom)));
                             values.Add(pv);
                         }
                     }
                 }
             }
         }
     }
     return values;
 }