DapperLib / Dapper.Contrib

Dapper community contributions - additional extensions for Dapper
Other
263 stars 96 forks source link

SQL logic error near ")": syntax error - with Contrib #34

Open mshami85 opened 6 years ago

mshami85 commented 6 years ago

Hi I've noticed that when making superclass as DAL containing CRUD operation with SQLite it always give this error the code is like that

public abstract class DataEntity : IDisposable
{ 
        public virtual void Insert()
        {
                using (var db = ConFactory.Connection)
                {
                    db.Open();
                    var tr = db.BeginTransaction();
                    db.Insert(this, tr);
                    tr.Commit();
                }
        }
}

and my classes looks like that

[Table("[test]")]
    public class Test : DataEntity
    {
        [Key]
        public int TestId { get; set; }

        public string Name { get; set; }
    }

using the code like this will result SQL logic error near ")": syntax error

using (Test t = new Test { Name = textBox2.Text })
{
     t.Insert();
     textBox1.Text = t.TestId.ToString();
 }

BUT when Insert method dragged to [Test] class it works perfectly

MelbourneDeveloper commented 4 years ago

@mshami85 I'm getting this error suddenly. The insert was working fine at some point, but something I've changed has broken it. The problem I see is that we cannot see what SQL was executed. Why doesn't exception expose the insert statement so we've got any idea of what went wrong?

wobbet commented 2 years ago

I'm seeing this same issue as well... Super simple code var num = conn.Insert(item);

When I debug through decompiled source it is detecting a value for T of "object" and returning a table name of Objects as where to store the item. When I'm debugging I clearly see the type of the object as, in my case, BadActor.

Environment