public IPathNode SetItem(IContext context, string path, object value)
        {
            var factory = new DynamicParametersFactory(_context, _record.Table.TableName);

            //TODO: invert sql generation and parameter snooping to update only specified fields
            var cmd = factory.ToUpdate();

            context.WriteVerbose("UPDATE SQL: " + cmd.CommandText);
            
            factory.Parameterize(cmd, PrimaryKey, value, context.DynamicParameters as RuntimeDefinedParameterDictionary);

            cmd.ExecuteNonQuery();
            return GetNodeValue();
        }
        public IPathNode SetItem(IContext context, string path, object value)
        {
            var factory = new DynamicParametersFactory(_context, _record.Table.TableName);

            //TODO: invert sql generation and parameter snooping to update only specified fields
            var cmd = factory.ToUpdate();

            context.WriteVerbose("UPDATE SQL: " + cmd.CommandText);

            factory.Parameterize(cmd, PrimaryKey, value, context.DynamicParameters as RuntimeDefinedParameterDictionary);

            cmd.ExecuteNonQuery();
            return(GetNodeValue());
        }
Exemple #3
0
        public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue)
        {
            var parameterDictionary = context.DynamicParameters as RuntimeDefinedParameterDictionary;
            var value = newItemValue.ToPSObject();

            var factory = new DynamicParametersFactory(_context, Name);
            var command = factory.ToInsert();

            context.WriteVerbose("INSERT SQL: " + command.CommandText);

            factory.Parameterize(command, value, parameterDictionary);

            foreach (SqliteParameter param in command.Parameters)
            {
                context.WriteVerbose("PARAMETERS: @" + param.ParameterName + " = [" + param.Value + "]");
            }

            var id = command.ExecuteScalar();

            return(Resolve(context, id.ToString()).First().GetNodeValue());
        }
        public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue)
        {
            var parameterDictionary = context.DynamicParameters as RuntimeDefinedParameterDictionary;
            var value = newItemValue.ToPSObject();
            
            var factory = new DynamicParametersFactory(_context, Name);
            var command = factory.ToInsert();
            
            context.WriteVerbose( "INSERT SQL: " + command.CommandText );

            factory.Parameterize(command, value, parameterDictionary);

            foreach (SqliteParameter param in command.Parameters)
            {
                context.WriteVerbose("PARAMETERS: @" + param.ParameterName + " = [" + param.Value + "]");
            }

            var id = command.ExecuteScalar();
            
            return Resolve(context, id.ToString()).First().GetNodeValue();
        }