Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, November 25, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 External Development Forums - General External Development
Forum to discuss general external development topic (related or not to SalesLogix development). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to General External Development | New ThreadView:  Search:  
 Author  Thread: How to use pre-generated keys with entity framework.
Matthew Arnold
Posts: 6
 
How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Dec 12 1:37 PM
fiogf49gjkf0d

Is it possible to use pre-generated keys with the entity framework.


 


1. Retrive a generated key.


2. Create an entity(Contact for example), set the key value to the generated key, then save.


 


I need the OnCreate and OnBeforeInsert events to fire which is why Im not just inserting the record into the datbase with the generated key value. 

[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Dec 12 7:07 AM
fiogf49gjkf0d

Hi Matthew,


What method are you using to import the new record? If you are calling to the framework your associated entity events should fire. IF you are trying to push them in via SQL or such, they will not.


 


Carla

[Reply][Quote]
Matthew Arnold
Posts: 6
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Dec 12 8:14 AM
fiogf49gjkf0d

Im using a business rule.


 


The problem im having is being able to create a new entity with the framework and setting its Id property. Its read only. Was looking for a work around if one existed.

[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Dec 12 8:33 AM
fiogf49gjkf0d

OK, let me make sure I understand what you are saying.  You will be *inside* of SalesLogix while creating a new record, but you don't want to use the UID generation provided with SalesLogix, nor the Insert method?  Is that correct?


Are you using pre-generated SLX numbers?  If you are trying to provide your own UID; I would strongly recommend against it.  There are a number of underpinnings in the product that could get completely out of whack.

[Reply][Quote]
Matthew Arnold
Posts: 6
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Dec 12 8:44 AM
fiogf49gjkf0d

When you said "Insert method" in your last post, do you mean a sql insert or a method in the framework named "Insert"?


 


If sql insert, then thats not an option since events want fire. 


 


Short story:


Writing a disconnected client that primarly uses sdata. We generate a sage formatted key with its on site code. However, sdata does not support sending a key during creation. Next though was to use a business rule to do the creation.


 


 

[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Dec 12 9:03 AM
fiogf49gjkf0d

OK, now that we have cleared up what type of insert you are trying to accomplish, I am wondering why you aren't using the disconnected client to do the work for you.  It will handle all of that (site code included) and fire the required rules when it sends data up.  I think I am missing something else here as recreating the record and sending it via sdata is a redundant process. 


Can you please let us know why you are doing this so we can help figure out the best method for you to use?

[Reply][Quote]
Matthew Arnold
Posts: 6
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Dec 12 9:33 AM
fiogf49gjkf0d

My fault on lack of info. 


 


This is a custom disconnected client without sage installed on the device. 

[Reply][Quote]
Matthew Arnold
Posts: 6
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Dec 12 9:58 AM
fiogf49gjkf0d

The SalesLogix application is not installed on the device. Its sort of mimicing a disconnected client. The part I'm working on is the syncronization. This is also on a very small scale. Only a couple of entities.


 


Thanks for the replys so far. 

[Reply][Quote]
Steve
Posts: 3
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Dec 12 6:11 AM
fiogf49gjkf0d

Quote:
Originally posted by Matthew Arnold


Is it possible to use pre-generated keys with the entity framework.


 


1. Retrive a generated key.


2. Create an entity(Contact for example), set the key value to the generated key, then save.


 


I need the OnCreate and OnBeforeInsert events to fire which is why Im not just inserting the record into the datbase with the generated key value. 



 


Try this if it helps


                        Dim PregenKey


                        PregenKey =  Application.BasicFunctions.GetIDFor("C_My_Table_Name")


Comment: "C_My_Table_Name" being the name of the table


 


 

[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Dec 12 11:02 AM
fiogf49gjkf0d

Ok, and the reason you don't want to use sData insert is because you wan tyour pregenerated keys to have a particular sitecode in the key, is that correct or is there another reason you want your pregenerated keys?

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Dec 12 12:21 PM
fiogf49gjkf0d

Hey Matthew,


Sadly, neither the entity framework or SData allow you to specify the ID for the record you are creating. This can be a huge pain at times. For me this is usually because I want to do things with the record ID before the actual record gets created (like create a pretty key). Instead I usually rearrage my workflow so I create the record, then get the key and do whatever I needed to do with it. Sadly, though, if you're wanting to specify some custom ID value to use, this won't work on an update either. Only way to do it is using a business rule that bypasses the entiy framework and updates the SQL table directly with the custom ID value (easy enough to do using the DataService).


Ryan

[Reply][Quote]
Matthew Arnold
Posts: 6
 
Re: How to use pre-generated keys with entity framework.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Dec 12 3:18 PM
fiogf49gjkf0d

Hey Ryan,


Thanks for the reply.


I had a feeling this was going to be the answer, but wanted to hear from the experts.


 


Thanks

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/25/2024 7:00:56 PM