DapperLib / DapperLib/Dapper.Contrib

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

Open
#34 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
293
Forks
109
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the SQLite insert with the abstract DataEntity.Insert method and compare it with the same method placed directly on Test. Trace how db.Insert(this, tr) determines the table and columns for the inherited object; done means both forms insert successfully and assign TestId without the syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sqlite
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.