An object or column name is missing or empty

Posts   
 
    
ElQueso avatar
ElQueso
User
Posts: 27
Joined: 08-Oct-2005
# Posted on: 30-May-2009 02:36:15   

I am using the latest version (2.6.09.0511), just downloaded, updated and verified in my references et al.

I get the following error message when I try to save an entity. The error is happening during the refetch on a specific entity type a few levels down in the entity hierarchy.

Message:

An exception was caught during the execution of a retrieval query: An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name. . Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

Stack Trace:

at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PerformExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, CommandBehavior behavior)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFields2 fieldsToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfos, IRelationPredicateBucket filter)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, IRelationPredicateBucket filter, ExcludeIncludeFieldsList excludedIncludedFields)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, Int32& totalAmountSaved)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse)
   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave)
   at Chevron.Completions.BLL.BLManager.Save() in D:\HappyCoders\Clients\ChevronTexaco\Subversion\Completions\VisualStudio\Chevron.Completions.BLL\BLManager.cs:line 1210

Query:

Query: SELECT [Completions].[dbo].[WorkstringSections].[CompletionJobID], [Completions].[dbo].[WorkstringSections].[TopDepth], [Completions].[dbo].[WorkstringSections].[WorkstringLength], [Completions].[dbo].[WorkstringSections].[TubularID], [Completions].[dbo].[WorkstringSections].[MetallurgyID], [].[Metallurgy] FROM [Completions].[dbo].[WorkstringSections]  WHERE ( ( [Completions].[dbo].[WorkstringSections].[CompletionJobID] = @CompletionJobID1 AND [Completions].[dbo].[WorkstringSections].[TopDepth] = @TopDepth2))
    Parameter: @CompletionJobID1 : Guid. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 14a12cf1-f152-4d08-8918-ee6a0da72b63.
    Parameter: @TopDepth2 : Double. Length: 0. Precision: 38. Scale: 0. Direction: Input. Value: 0.

As you can see, the problem is in the select, on the column "[].[Metallurgy] " which is missing an alias it would seem.

I have an entity called WorkstringSectionEntity. A WorkstringSectionEntity has a MetallurgyID int field, foreign key to the Metallurgies table. I prefetch the MetallurgyEntity into the WorkstringSectionEntity on opening and creating a new WorkstringSectionEntity.

The field in question is actually a "field on related field" from the MetallurgyEntity.Metallurgy field, which is a string field of the same name on the WorkstringSectionEntity.

If I put a record manually in the database, the entity fetches fine and the field WorkstringSectionEntity.Metallurgy returns the correct string every time.

However, as soon as I make a change to the data in the WorkstringSectionEntity I added to the database manually, I get the error again.

I might mention that I have another related entity that is exposes 8 "field on related field" to the WorkstringSectionEntity and these don't seem to be aproblem. They certainly don't show up in the query. I just didn't think the field that's having the problem from the Metallurgies table should be in there, since these type of fields are returned directly from the related entity.

The error seemed to come out of nowhere. I haven't regenerated the data layer in months and just not sure what could be the root cause of this.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-May-2009 06:10:45   

Hi ElQueso.

Weird indeed. Please post the code snippet that generates such exception. Does the error comes when you upgraded to the latest version? or is new code?

David Elizondo | LLBLGen Support Team
ElQueso avatar
ElQueso
User
Posts: 27
Joined: 08-Oct-2005
# Posted on: 30-May-2009 06:22:31   

adapter.StartTransaction(IsolationLevel.ReadCommitted, "CompleteSave");
try
{
    if (!adapter.SaveEntity(well, true))
    {
        adapter.Rollback();
        return false;
    }

    ...other stuff

    adapter.Commit();
}
catch (Exception ex)
{
    adapter.Rollback();
    throw ex;
}

It's really pretty simple, the save. It's the SaveEntity method call that's failing. The "well" is the high-level entity, with a farly complex related entity hierarchy.

I was using a build from July of 2008 when I encountered this problem. I updated to the latest build when I ran into this, hoping it would fix it.

The truth is, the project has been sitting for about 4 months, and it was working fine last time we ran it. The project was mothballed, but I took it out to see about doing a demonstration and when I modified the entity mentioned in the previous post and tried to save, that's when it happened.

I'm clueless to think of anything I might have done re-opening the project that might have affected this.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 31-May-2009 19:54:37   

Will try to reproduce that today and post the results. If I can't reproduce it, would be helpful if you post some tiny repro solution we can use (including the DDL of the schema, some insert data, the lgp and some .net code), and you can start a private thread (Helpdesk forum) for that.

David Elizondo | LLBLGen Support Team
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Jun-2009 08:37:17   

Hola ElQueso. I can't reproduce your problem (latest build, similar scenario). It's unfortunate you run into this weird behavior. If you open a private thread (HelpDesk forum) and post some repo solution, we would be glad to help you in this.

David Elizondo | LLBLGen Support Team