BLToolkit: Trying to update an entity and getting “can't convert to SQL error”

StackOverflow https://stackoverflow.com/questions/5811915

  •  25-10-2019
  •  | 
  •  

سؤال

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.

هل كانت مفيدة؟

المحلول

The solution was about modifying BLToolkit sources.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top