You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PetaPoco in general works just fine with non-public classes, but I have discovered that multi-poco queries do not. I don't know much about IL generation, but I'm pretty sure it has to do with the function generated by MultiPocoFactory.CreateMultiPocoFactory(), especially the calls to Invoke().
Here's a LinqPad script using an in-memory SQLite db. It runs just fine as is, but if you change the access modifiers on the User and Article classes, you'll get an exception: MethodAccessException: Attempt by method 'DynamicClass.petapoco_multipoco_factory(PetaPoco.Internal.MultiPocoFactory, System.Data.IDataReader, System.Object)' to access method 'System.Func`2<System.__Canon,System.__Canon>.Invoke(System.__Canon)' failed.
voidMain(){varconfig= DatabaseConfiguration.Build().UsingConnectionString("Data Source=:memory:").UsingProvider<SQLiteDatabaseProvider>();using(vardb=new Database(config)){
db.KeepConnectionAlive =true;
db.Execute("CREATE TABLE IF NOT EXISTS User (ID INTEGER PRIMARY KEY, Name TEXT)");
db.Execute("CREATE TABLE IF NOT EXISTS Article (ID INTEGER PRIMARY KEY, UserID, INTEGER, Title TEXT)");
db.Insert("User",new{ Name ="Bob"});
db.Insert("User",new{ Name ="Jane"});
db.Insert("Article",new{ UserID =1, Title ="Epidemiology"});
db.Insert("Article",new{ UserID =1, Title ="Astronomy"});
db.Insert("Article",new{ UserID =2, Title ="Art"});
db.Insert("Article",new{ UserID =2, Title ="Soccer"});varq="select u.id, u.name, a.userid, a.title from user as u inner join article as a on u.id=a.userid";varrecs= db.Fetch<User,Article>(q).Dump();}}publicclassUser{publicintID{get;set;}publicstringName{get;set;}publicArticleArticle{get;set;}}publicclassArticle{publicstringTitle{get;set;}}
The text was updated successfully, but these errors were encountered:
PetaPoco in general works just fine with non-public classes, but I have discovered that multi-poco queries do not. I don't know much about IL generation, but I'm pretty sure it has to do with the function generated by MultiPocoFactory.CreateMultiPocoFactory(), especially the calls to
Invoke()
.Here's a LinqPad script using an in-memory SQLite db. It runs just fine as is, but if you change the access modifiers on the
User
andArticle
classes, you'll get an exception:MethodAccessException: Attempt by method 'DynamicClass.petapoco_multipoco_factory(PetaPoco.Internal.MultiPocoFactory, System.Data.IDataReader, System.Object)' to access method 'System.Func`2<System.__Canon,System.__Canon>.Invoke(System.__Canon)' failed.
The text was updated successfully, but these errors were encountered: