orm - How to get an object with change tracking in Dapper .Contrib? -


i've been playing dapper-contrib bit , having problem retrieving object using .get can maintain change tracking object.

my interface:

imports dapper.contrib.extensions  public interface icountry      <key>     property countryguid guid     property country string  end interface 

the class:

imports dapper.contrib.extensions  <table("country")> public class country     implements icountry     <key>     public property countryguid guid implements icountry.countryguid     public property country string implements icountry.country  end class 

my function:

   public function find(countryid guid) icountry         dim country icountry          using conn = new sqlconnection(connectionstring)             conn.open()              country = conn.get(of icountry)(countryid)              conn.close()         end using          return country     end function 

and got error saying invalid object name 'countrys' when calling above function.

the problem seems caused dapper sqlmapperextensions automatically adds “s” tablename , can solved defining tableattribute. however, tableattribute supported classes not interfaces.

please note have call .get interface have tracking functionality.

just wonder if has managed work?

much appreciated.

i had same problem , managed circumvent it.

looking @ test suite dapper contrib, found this code. created function modify table mapping

private static void configuretablemapper() {     if (sqlmapperextensions.tablenamemapper != null)         return;      sqlmapperextensions.tablenamemapper = (type) =>     {         var tableattr = type.getcustomattributes(false).singleordefault(attr => attr.gettype().name == "tableattribute") dynamic;         if (tableattr != null)             return tableattr.name;          var name = type.name;         if (type.isinterface && name.startswith("i"))             name = name.substring(1);         return name;     }; } 

it's c# code should converted vb.

hope helps !


Comments