Self-Servicing - Abstract Entities

Posts   
 
    
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 05-Jul-2007 22:53:00   

Hello Everyone,

I am using TargetPerEntity inheritence mapping (one table, multiple types). An entity of mine has a FieldMapped relation to a collection of these entities:

MyObject.MyAbstractObjects

I want to do the following:

MyObject.MyAbstractObjects.AddNew

My code will then assign the proper descriminator to the abstract object.

However, on that call, the code locks up ... It also seems to leave a table lock behind.

Is there a way I can create an abstract entity? Everything is done within a transaction.

Here is the SQL Log:

Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: TransactionBase.CTor Method Exit: TransactionBase.CTor Method Enter: DaoBase.PerformFetchEntityAction Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Generated Sql query: Query: SELECT [SubscriptionNotification].[dbo].[Contacts].[ContactID] AS [ContactId], [SubscriptionNotification].[dbo].[Contacts].[FirstName], [SubscriptionNotification].[dbo].[Contacts].[LastName], [SubscriptionNotification].[dbo].[Contacts].[LanguageID] AS [LanguageId], [SubscriptionNotification].[dbo].[Contacts].[UserID] AS [UserId], [SubscriptionNotification].[dbo].[Contacts].[ClientID] AS [ClientId], [SubscriptionNotification].[dbo].[Contacts].[Disabled], [SubscriptionNotification].[dbo].[Contacts].[Deleted] FROM [SubscriptionNotification].[dbo].[Contacts] WHERE ( [SubscriptionNotification].[dbo].[Contacts].[ContactID] = @ContactId1) Parameter: @ContactId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.

Method Exit: CreateSelectDQ Method Enter: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.PerformFetchEntityAction Method Enter: DaoBase.DeleteMulti(2) Method Enter: CreateDeleteDQ(6) Method Enter: CreateSingleTargetDeleteDQ(3) Generated Sql query: Query: DELETE FROM [SubscriptionNotification].[dbo].[ContactDestinationSchedules] WHERE ( [SubscriptionNotification].[dbo].[ContactDestinationSchedules].[ContactID] = @ContactId1) Parameter: @ContactId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.

Method Exit: CreateSingleTargetDeleteDQ(3) Method Exit: CreateDeleteDQ(6) Method Enter: DaoBase.ExecuteActionQuery The thread '<No Name>' (0x1ee4) has exited with code 0 (0x0). Method Enter: Query.ReflectOutputValuesInRelatedFields Method Exit: Query.ReflectOutputValuesInRelatedFields: no parameter relations. Method Exit: DaoBase.ExecuteActionQuery Method Exit: DaoBase.DeleteMulti(2) Method Enter: DaoBase.DeleteMulti(2) Method Enter: CreateDeleteDQ(6) Method Enter: CreateSingleTargetDeleteDQ(3) Generated Sql query: Query: DELETE FROM [SubscriptionNotification].[dbo].[ContactDestinations] WHERE ( [SubscriptionNotification].[dbo].[ContactDestinations].[ContactID] = @ContactId1) Parameter: @ContactId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.

Method Exit: CreateSingleTargetDeleteDQ(3) Method Exit: CreateDeleteDQ(6) Method Enter: DaoBase.ExecuteActionQuery Method Enter: Query.ReflectOutputValuesInRelatedFields Method Exit: Query.ReflectOutputValuesInRelatedFields: no parameter relations. Method Exit: DaoBase.ExecuteActionQuery Method Exit: DaoBase.DeleteMulti(2) Method Enter: TransactionBase.Save Method Exit: TransactionBase.Save Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Generated Sql query: Query: SELECT [SubscriptionNotification].[dbo].[ContactDestinations].[ContactID] AS [F0], [SubscriptionNotification].[dbo].[ContactDestinations].[DestinationTypeID] AS [F1], [SubscriptionNotification].[dbo].[ContactDestinations].[Destination] AS [F2], [SubscriptionNotification].[dbo].[ContactDestinations].[NotificationOrder] AS [F3], [SubscriptionNotification].[dbo].[ContactDestinations].[TimeZoneID] AS [F4], [SubscriptionNotification].[dbo].[ContactDestinations].[Disabled] AS [F5], [SubscriptionNotification].[dbo].[ContactDestinations].[TextMessageCarrierID] AS [F6] FROM [SubscriptionNotification].[dbo].[ContactDestinations] WHERE ( [SubscriptionNotification].[dbo].[ContactDestinations].[DestinationTypeID] IN (@DestinationTypeId1, @DestinationTypeId2, @DestinationTypeId3, @DestinationTypeId4, @DestinationTypeId5, @DestinationTypeId6, @DestinationTypeId7, @DestinationTypeId8, @DestinationTypeId9, @DestinationTypeId10) AND ( [SubscriptionNotification].[dbo].[ContactDestinations].[ContactID] = @ContactId11)) Parameter: @DestinationTypeId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0. Parameter: @DestinationTypeId2 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1999. Parameter: @DestinationTypeId3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2000. Parameter: @DestinationTypeId4 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1000. Parameter: @DestinationTypeId5 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 3000. Parameter: @DestinationTypeId6 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1003. Parameter: @DestinationTypeId7 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2001. Parameter: @DestinationTypeId8 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1001. Parameter: @DestinationTypeId9 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2002. Parameter: @DestinationTypeId10 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1002. Parameter: @ContactId11 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.

Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery

The last command dies - Lockup.

Thanks!

mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 05-Jul-2007 23:34:12   

OK FIGURED IT OUT...

.ADDNEW doesn't set the new Entities Transaction? This caused the entity to be OUTSIDE of the transaction and conflicted with the current transaction.

Is this normal??? How come if the parent entity is in a transaction, shouldn't .ADDNEW assign the new child entity's transaction too?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Jul-2007 11:09:10   

ADDNEW doesn't set the new Entities Transaction? This caused the entity to be OUTSIDE of the transaction and conflicted with the current transaction.

Is this normal??? How come if the parent entity is in a transaction, shouldn't .ADDNEW assign the new child entity's transaction too?

That's normal, you should add the new entity to the transaction.

Maybe you want to use a UnitOfWork, where you can specify recurse, when adding an entity for save.