Iam planning to use Contrib with dapper to make my classes in desktop applications look like this
public abstract class DB : IDisposable
{
public virtual long Insert()
{
using (var db = ConFactory.GetConnection())
{
db.Open();
return db.Insert(this);
}
}
// ... and other CRUD operations
}
then any Concept class will inherits from DB class; like this
[Table("test")]
public class Test : DB
{
[Key]
public int TestId { get; set; }
public string Name { get; set; }
}
using Test class
using (Test t = new Test { Name = textBox2.Text })
{
textBox1.Text = t.Insert().ToString();
}
this sample always fails and gives me
SQL logic error near ")": syntax error
BUT when I implement Insert()
method inside child class it works well !!!
the problem is: my code contains lot of classes, rewrite All CUD operations is so disturbing,
any idea to solve this with less code?