phnx47 / dapper-repositories

CRUD for Dapper
MIT License
664 stars 203 forks source link

System.NotSupportedException: 'predicate can't parse' #72

Closed freetison closed 6 years ago

freetison commented 6 years ago

I am trying to replicate the MsSqlRepositoriesTests but I received this runtime error: System.NotSupportedException: 'predicate can't parse'

POCO class

[Table("TestTableSize")] public class TestTableSize { [Column(TypeName = "varchar"), MaxLength(10)] public string MyKeyField; // varchar(10), not null

    [Column(TypeName = "datetime")]
    public DateTime? MyDate1; // datetime, not null
}

--Code--- var testConnectionString = "Data Source=DOOM\SCOM;Initial Catalog=testAdminSQL;Integrated Security=True";

MsSqlDbContext db = new MsSqlDbContext(testConnectionString); var test = db.TestTableSize.Find(x => x.MyKeyField == "0002720715"); // Exception

phnx47 commented 6 years ago

Why do you use 'field' and not 'property'. I think this is the problem.

freetison commented 6 years ago

Thanks for answer and your incredible work. You are right.. It's fix using properties.

tonnystark commented 4 years ago

Thanks for answer and your incredible work. You are right.. It's fix using properties.

How can you fix this? I've the same problem when using DateTime. Ex: (t.CreatedDate.Subtract(currentDate).Days == 0)

phnx47 commented 4 years ago

@tonnystark It is difficult query for parse. You can use SQL directly in Dapper.

tonnystark commented 4 years ago

L direct

Thanks for your comment, I'll do that.