Weird FetchEntity bug HELP ASAP

Posts   
 
    
VbMan
User
Posts: 6
Joined: 28-Nov-2006
# Posted on: 11-Dec-2006 23:53:30   

This is the second project I have recieved this bug. It is of the same natue. I forgot to put a column name in the database (MiscName) and I then refereshed the catalog in LLBLPro. I recompiled the datalayer, removed the references and re-added the references to my main application.

I then get the following message. I have ensured that the column name is visible within LLBLPro UI and I can even insert a new record with that field name as well. It shows up in Intellisense but when I go to retrieve that record it fails:


The field name 'ShowName' isn't known in the element 'ShowsEntity' Parameter name: fieldName

Exception Details: System.ArgumentException: The field name 'ShowName' isn't known in the element 'ShowsEntity' Parameter name: fieldName

Source Error:

Line 190: Dim adapter As New DL.DatabaseSpecific.DataAccessAdapter Line 191: Line 192: If (adapter.FetchEntity(Show)) Then Line 193: Me.ShowName.Text = Show.ShowName Line 194: Return True

Source File: C:\Inetpub\wwwroot\SbHomeShowSEM\ShowInfo.aspx.vb Line: 192

Stack Trace:

[ArgumentException: The field name 'ShowName' isn't known in the element 'ShowsEntity' Parameter name: fieldName] SD.LLBLGen.Pro.ORMSupportClasses.PersistenceInfoProviderBase.GetFieldPersistenceInfo(String elementName, String fieldName) SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.GetFieldPersistenceInfo(IEntityField2 field) SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.GetFieldPersistenceInfos(IEntityFields2 fields) SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch) SbHomeShowSEM.ShowInfo.getShowName() in C:\Inetpub\wwwroot\SbHomeShowSEM\ShowInfo.aspx.vb:192 SbHomeShowSEM.ShowInfo.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\SbHomeShowSEM\ShowInfo.aspx.vb:59 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive()


'ShowName' is the new column I added to the table.

Finally, this code works fine with the new column name:

    Dim nsrtShow As New DL.EntityClasses.ShowInfoPageEntity
    Dim adapter As DL.DatabaseSpecific.DataAccessAdapter

    With nsrtShow
        .ShowId = CInt(Me.lbl_ShowID.Text)
        .Title = Me.Title.Text
        .ImgSrc = Me.ImgSrc.Text
        .Paragraph = Me.Paragraph.Text
        .Footer = Me.Footer.Text
    End With

    nsrtShow.IsNew = True
    adapter = New DL.DatabaseSpecific.DataAccessAdapter
    If (adapter.SaveEntity(nsrtShow)) Then Return True
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Dec-2006 06:55:12   

Would you please try to set a value for the ShowName field when inserting (in the code)?

Most probably you need to re-generate the code and make sure you are actually using the newly generated code, rather than another old version residing in the GAC or something. Make sure that you are using the latest generated DBSpecific project.

VbMan
User
Posts: 6
Joined: 28-Nov-2006
# Posted on: 12-Dec-2006 19:24:12   

Yes, I did and double checked that first. I also ensured I set the primary key prior to fetching the object.

I recompiled the DL both DBSPECIFIC and DBGENERIC and it appears that fixes it. I was under the impression DBSPECIFIC only took care of the database handling tasks such as connection and the such, is this not the case? Is it not abstracted into two layers, one being the entities and the object I use and the other being the persistence and db managment of connections and command execution?

Thank you so much for your help. The product has still saved me time even with this misunderstanding of the code.

~Mann.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 12-Dec-2006 20:02:52   

DBSpecific project takes care of the mapping between an entity field and a table/view field. So if you pass in an entity with 10 fields, and the dbspecific project knows mappings of 8 fields, because it's not the dbspecific project generated at the same time as the dbgeneric project, you'll run into a problem, because the 2 fields without mapping info will cause problems which you've seen.

Frans Bouma | Lead developer LLBLGen Pro