DeleteEntitiesDirectly with subclasses

Posts   
 
    
tmatelich
User
Posts: 95
Joined: 14-Oct-2009
# Posted on: 18-Feb-2010 23:27:33   

Is there a trick to this? AFAICT, the query is asking the database to know about the link between the two tables without describing it. Perhaps inheritance isn't as automagical as I thought.

Postgres 8.3, 12/24 runtime libraries w/ 2.6 final generated code.

Using my DDL from http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=17424 I am doing an

adapter.DeleteEntitiesDirectly(typeof(ReportEntryEntity), B);

(B is a RelationPredicateBucket). It is failing, with the following exception:

SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of an action query: ERROR: 42P01: missing FROM-clause entry for table "core_report_entries". Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception. ---> Npgsql.NpgsqlException: missing FROM-clause entry for table "core_report_entries" Severity: ERROR Code: 42P01 at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext() in C:\projects\Npgsql2\src\Npgsql\NpgsqlState.cs:line 832 at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1136 at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1154 at Npgsql.ForwardsOnlyDataReader.NextResult() in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1340 at Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError) in C:\projects\Npgsql2\src\Npgsql\NpgsqlDataReader.cs:line 1003 at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb) in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 589 at Npgsql.NpgsqlCommand.ExecuteNonQuery() in C:\projects\Npgsql2\src\Npgsql\NpgsqlCommand.cs:line 493 at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() --- End of inner exception stack trace --- at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteActionQuery(IActionQuery queryToExecute) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.DeleteEntitiesDirectly(String entityName, IRelationPredicateBucket filterBucket) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.DeleteEntitiesDirectly(Type typeOfEntity, IRelationPredicateBucket filterBucket)

Here is the diagnostic output

Method Enter: DataAccessAdapterBase.DeleteEntitiesDirectly

Deleting entities of type: ReportEntryEntity Method Enter: CreateDeleteDQ(6) Method Enter: CreateSingleTargetDeleteDQ(3) Generated Sql query: Query: DELETE FROM "public"."report_entries" WHERE ( ( ( "public"."core_report_entries"."vessel" = :Vessel1 AND "public"."core_report_entries"."outage" = frowning utage2 AND "public"."core_report_entries"."calgroup_name" = :CalgroupName3 AND "public"."core_report_entries"."data_file_name" = smile ataFileName4))) Parameter: :Vessel1 : String. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: "11". Parameter: frowning utage2 : String. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: "1R20". Parameter: :CalgroupName3 : String. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: "SG11CCAL00004". Parameter: smile ataFileName4 : String. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: "DCR003C122I009".

Method Exit: CreateSingleTargetDeleteDQ(3)
Method Exit: CreateDeleteDQ(6)
Method Enter: DataAccessAdapterBase.ExecuteActionQuery
Method Enter: DataAccessAdapterBase.OpenConnection
Connection physically opened. Method Exit: DataAccessAdapterBase.OpenConnection A first chance exception of type 'Npgsql.NpgsqlException' occurred in Npgsql.dll A first chance exception of type 'Npgsql.NpgsqlException' occurred in Npgsql.dll A first chance exception of type 'SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException' occurred in SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Feb-2010 03:33:15   

I'm afraid that DeleteEntitiesDirectly with a hierarchy of TargetPerEntity isn't supported. Here is more explanation: http://llblgen.com/tinyforum/Messages.aspx?ThreadID=12085

David Elizondo | LLBLGen Support Team
tmatelich
User
Posts: 95
Joined: 14-Oct-2009
# Posted on: 19-Feb-2010 07:08:39   

Note to self: do your research on something before jumping in with both feet.

It might be nice to have this limitation documented. If I just missed it, maybe the blink tag could be employed simple_smile .

This and the pain I'm feeling trying to do bulk import tells me that perhaps I don't want a hierarchy as much as I thought I did.

Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 19-Feb-2010 08:47:47   

Note to self: do your research on something before jumping in with both feet.

simple_smile

Yeah, hierarchies should not be over used.

tmatelich
User
Posts: 95
Joined: 14-Oct-2009
# Posted on: 19-Feb-2010 14:44:22   

Is there a semi-painless way to introduce a base class or interface for two entities which are 90% identical to avoid code duplication?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 19-Feb-2010 17:02:24   

tmatelich wrote:

Is there a semi-painless way to introduce a base class or interface for two entities which are 90% identical to avoid code duplication?

Interface: use the Code gen options in the entity editor and specify an interface there. You then have to implement it manually in a partial class (so for each entity you implement the interface on)

base class: not that easy.

In v3 we solved this: you can specify the base class for each entity individually if you want to, which makes introducing a class below some entity class easy.

Frans Bouma | Lead developer LLBLGen Pro
tmatelich
User
Posts: 95
Joined: 14-Oct-2009
# Posted on: 19-Feb-2010 17:07:29   

Great, thanks!