Question

I have an update method:

protected int ProcessUpdate(TUpdateDto updateDto, Func<IQueryable<TEntity>, IUpdateable<TEntity>> firstSetter, params Func<IUpdateable<TEntity>, IUpdateable<TEntity>>[] setters)       
    {
        Checker.AssertNull(updateDto);
        int id = updateDto.Id.FailIfNull();

        IQueryable<TEntity> query = from item in new Table<TEntity>()
                                    where item.Id == id
                                    select item;

        IUpdateable<TEntity> updateable = firstSetter(query);

        foreach (var setter in setters)
        {
            setter(updateable);
        }

        Checker.AssertNull(updateable);
        updateable.Update();

        return id;
    }

And entity:

[TableName("Test")]
public class Test
{
    [PrimaryKey, Identity]
    public int Id { get; set; }

    public string Field1 { get; set; }
}

And here is the update code:

 ProcessUpdate(updateDto, x => x.Set(e => e.Id, updateDto.Id), 
                          x => x.Set(e => e.Field1, updateDto.Field1));

When I try to update an entry in a table I get "'Convert(item).Id' cannot be converted to SQL." error. I have tried not to update id and results were the same. I wish I could find the solution, but I can not. Thanks for your answers.

Was it helpful?

Solution

The solution was about modifying BLToolkit sources.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top