This project is read-only.
1
Vote

Linq2Sql data objects creation problem

description

It looks like that AutoPoco cant create Linq2Sql data objects.

Code:
IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
{
x.Conventions(c => c.UseDefaultConventions());
x.AddFromAssemblyContainingType<Account>();
});

IGenerationSession session = factory.CreateSession();

Account account = session.Single<Account>().Get();


Exception:
System.Reflection.TargetParameterCountException was unhandled by user code
Message=Parameter count mismatch.
Source=mscorlib
StackTrace:
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at AutoPoco.Engine.ObjectPropertySetFromSourceAction.Enact(IGenerationContext context, Object target) in D:\tmp\autopoco_f8e6ff56736c\AutoPoco\Actions\ObjectPropertySetFromSourceAction.cs:line 26
   at AutoPoco.Engine.ObjectBuilder.EnactActionsOnObject(IGenerationContext context, Object createdObject) in D:\tmp\autopoco_f8e6ff56736c\AutoPoco\Engine\ObjectBuilder.cs:line 112
   at AutoPoco.Engine.ObjectBuilder.CreateObject(IGenerationContext context) in D:\tmp\autopoco_f8e6ff56736c\AutoPoco\Engine\ObjectBuilder.cs:line 102
   at AutoPoco.Engine.ObjectGenerator`1.Get() in D:\tmp\autopoco_f8e6ff56736c\AutoPoco\Engine\ObjectGenerator.cs:line 27
   at AutoPoco.Engine.GenerationContext.Next[TPoco]() in D:\tmp\autopoco_f8e6ff56736c\AutoPoco\Engine\GenerationContext.cs:line 82
InnerException:


I tried it with 1.0 version and last version from Source Code.
Look at complete solution in attach.

file attachments

comments

xkrt wrote Feb 3, 2011 at 11:27 AM

Actually problem with System.Data.Linq.Binary type (RowVersion property).
Please, look at updated solution in attachment.

robashton wrote Feb 3, 2011 at 1:29 PM

Okay - this will be because AP doesn't know how to construct that object - for now you can add a rule for the creation of it (Look at ConstructWith in trunk) - I might add it to the default boot-strapper as it's probably quite a common scenario