Exemple #1
0
        private string BuildValueString(IProvider provider, PropertyFieldMapping mapping, DbParameterCollection parameters, object value, int index, int batch)
        {
            var sb = new StringBuilder();

            var converter = ConvertManager.GetConverter(mapping.PropertyType);

            if (converter != null)
            {
                value = converter.ConvertTo(value, mapping.FieldType);
            }

            if (value is Enum)
            {
                sb.Append((int)value);
            }
            else if (NeedPutParameters(mapping.FieldType, value))
            {
                var prefix        = provider.GetService <ISyntaxProvider>().ParameterPrefix;
                var parameterName = AddOrReplayParameter(parameters, mapping.FieldType, ref value, index, batch,
                                                         () => provider.DbProviderFactory.CreateParameter());

                sb.AppendFormat("{0}{1}", prefix, parameterName);
            }
            else if (value is string || value is Guid)
            {
                sb.AppendFormat("'{0}'", value);
            }
            else
            {
                sb.Append(value);
            }

            return(sb.ToString());
        }
        private static void MapProperty(TResponse responseData, PropertyFieldMapping mapping, XContainer contentElement)
        {
            var fieldNode = contentElement.Elements(XName.Get(mapping.FieldName)).FirstOrDefault();

            switch (fieldNode)
            {
            case { FirstNode: null } :