Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Retrieving the record identity value after insert new record
 

Pages: 1
LLBLGen Pro Runtime Framework
Retrieving the record identity value after insert new record
Page:1/1 

  Print all messages in this thread  
Poster Message
RamiMoj
User



Location:

Joined on:
21-Feb-2019 07:32:50
Posted:
3 posts
# Posted on: 21-Feb-2019 08:58:21. Goto attachments  
Dear All;
After Greeting...
I have problem when I try to get the entity's identity field value after saving the new one ("Specified cast is not valid" message is appear). I am using oracle data base, and the entity 's identity field((primary key of table) is joined to some sequence item. Please, help to to solve this issue asap (see attachment file to more explaining).

My Code:

DeletingRequestEntity deletingRequest= new DeletingRequestEntity();
deletingRequest.DeletingRequestTypeId = deletingRequest.DeletingRequestTypeId;
deletingRequest.DeletingRequestStatusId = deletingRequest.DeletingRequestStatusId;
deletingRequest.CaseId = deletingRequest.CaseId;
deletingRequest.DeletedRecordId = deletingRequest.DeletedRecordId;
deletingRequest.DeletingReason = deletingRequest.DeletingReason;
deletingRequest.RequestDate = DateTime.Now;
if (deletingRequest.Save())
                {                    
                    int delRequestId =
                    Convert.ToInt32(deletingRequest.DeletingRequestId);
                
                }

Thank You

Best Regards;
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37196 posts
# Posted on: 21-Feb-2019 10:38:11.  
https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7722

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
RamiMoj
User



Location:

Joined on:
21-Feb-2019 07:32:50
Posted:
3 posts
# Posted on: 21-Feb-2019 11:01:56.  
- LLBLGen Pro V5.1 (5.1.1) RTM
- .Net framework 4.5
- Oracle 12 g
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14424 posts
# Posted on: 22-Feb-2019 02:19:05.  
What's the DB Type and the mapped .NET type of that PK?

P.S. What is the following code doing?
Code:
deletingRequest.DeletingRequestTypeId = deletingRequest.DeletingRequestTypeId;
deletingRequest.DeletingRequestStatusId = deletingRequest.DeletingRequestStatusId;
deletingRequest.CaseId = deletingRequest.CaseId;
deletingRequest.DeletedRecordId = deletingRequest.DeletedRecordId;
deletingRequest.DeletingReason = deletingRequest.DeletingReason;


  Top
RamiMoj
User



Location:

Joined on:
21-Feb-2019 07:32:50
Posted:
3 posts
# Posted on: 24-Feb-2019 07:12:40.  
- DB is oracle 12g
- Type of PK is number (decimal)
- This is a simplify to my code:
DeletingRequestEntity deletingRequest = new DeletingRequestEntity();
deletingRequest.DeletingReason = "Test";
if (deletingRequest.Save())
{                    
     int delRequestId = Convert.ToInt32(deletingRequest.DeletingRequestId); // Incremental primary key
}


  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8022 posts
# Posted on: 25-Feb-2019 06:17:38.  
RamiMoj wrote:
Code:
DeletingRequestEntity deletingRequest= new DeletingRequestEntity();
deletingRequest.DeletingRequestTypeId = deletingRequest.DeletingRequestTypeId;
deletingRequest.DeletingRequestStatusId = deletingRequest.DeletingRequestStatusId;
deletingRequest.CaseId = deletingRequest.CaseId;
deletingRequest.DeletedRecordId = deletingRequest.DeletedRecordId;
deletingRequest.DeletingReason = deletingRequest.DeletingReason;
deletingRequest.RequestDate = DateTime.Now;

Above code is weird. You are assigning an object's property to the same value's property...
Code:
deletingRequest.DeletingRequestTypeId = deletingRequest.DeletingRequestTypeId;

So please double check that.

About your second example. Does it work?
Code:
DeletingRequestEntity deletingRequest = new DeletingRequestEntity();
deletingRequest.DeletingReason = "Test";
if (deletingRequest.Save())
{                    
     int delRequestId = Convert.ToInt32(deletingRequest.DeletingRequestId); // Incremental primary key
}


If it doesn't work please double check that:
- The sequence is mapped in your entity's mapping. The sequence should be selected in the sequence's combos, if it doesn't, do it yourself manually. ref...

- If your sequence is Trigger-based please read this...


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.