Exception while projecting stored procedure onto entity collection

Posts   
 
    
Zaydoune
User
Posts: 10
Joined: 05-Mar-2008
# Posted on: 29-Apr-2008 10:57:17   

Hi, i'm trying to project a stored procedure resultset onto entity collection.

The sp return 4 fields : 2 strings and 2 real number.

While projecting : valueProjectors.Add(NewDataValueProjector(ProcperspectiveFieldIndex.Representant.ToString(),0)) valueProjectors.Add(New DataValueProjector(ProcperspectiveFieldIndex.Nom.ToString(),1))

No problem, but after this line

valueProjectors.Add(New DataValueProjector(ProcperspectiveFieldIndex.Solde.ToString(), 2))

i have a exception :

The value 26044,299446106 is of type 'System.Double' while the field is of type 'System.Single'

************** Texte de l'exception **************
SD.LLBLGen.Pro.ORMSupportClasses.ORMValueTypeMismatchException: The value 26044,299446106 is of type 'System.Double' while the field is of type 'System.Single'
   à SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.ValidateValue(IEntityField fieldToValidate, Object& value, Int32 fieldIndex)
   à SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.SetValue(Int32 fieldIndex, Object value, Boolean checkForRefetch, Boolean performDesyncForFKFields)
   à SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.SetNewFieldValue(Int32 fieldIndex, Object value)
   à SD.LLBLGen.Pro.ORMSupportClasses.DataProjectorToIEntityCollection.AddProjectionResultToContainer(IList projectors, Object[] rawProjectionResult)
   à SD.LLBLGen.Pro.ORMSupportClasses.DataProjectorToIEntityCollection.SD.LLBLGen.Pro.ORMSupportClasses.IGeneralDataProjector.AddProjectionResultToContainer(List`1 valueProjectors, Object[] rawProjectionResult)
   à SD.LLBLGen.Pro.ORMSupportClasses.ProjectionUtils.FetchProjectionFromReader(List`1 valueProjectors, IGeneralDataProjector projector, IDataReader datasource, Int32 maxNumberOfItemsToReturn, Int32 pageNumber, Int32 pageSize, Boolean clientSideLimitation, Boolean clientSideDistinctFiltering, Boolean clientSidePaging)
   à SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetAsProjection(List`1 valueProjectors, IGeneralDataProjector projector, IDataReader reader)
   à TypedListsTest.Form1.Form1_Load(Object sender, EventArgs e) dans C:\Documents and Settings\charf\Mes documents\Visual Studio 2005\Projects\Tests\TypedListsTest\TypedListsTest\Form1.vb:ligne 91
   à System.EventHandler.Invoke(Object sender, EventArgs e)
   à System.Windows.Forms.Form.OnLoad(EventArgs e)
   à System.Windows.Forms.Form.OnCreateControl()
   à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   à System.Windows.Forms.Control.CreateControl()
   à System.Windows.Forms.Control.WmShowWindow(Message& m)
   à System.Windows.Forms.Control.WndProc(Message& m)
   à System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   à System.Windows.Forms.ContainerControl.WndProc(Message& m)
   à System.Windows.Forms.Form.WmShowWindow(Message& m)
   à System.Windows.Forms.Form.WndProc(Message& m)
   à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Zaydoune
User
Posts: 10
Joined: 05-Mar-2008
# Posted on: 29-Apr-2008 17:53:50   

No idea?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 29-Apr-2008 18:57:25   

As the exception suggests... the value you want to project is of a different type. So it needs conversion.

You can achieve that. You need to create a derived class from DataValueProjector which allows you to override the postprocess routine. This will allow you to convert the value.

However, a type mismatch usually suggests that the value is projected onto the wrong field?

Frans Bouma | Lead developer LLBLGen Pro
Zaydoune
User
Posts: 10
Joined: 05-Mar-2008
# Posted on: 30-Apr-2008 15:23:55   

It works, thank you Otis