A question came up yesterday with regards to how to create SalesLogix ids within the Web Framework. In the legacy client and our external development we would generally call a provider Stored procedure that would give us the Id. The code might look as the following

List<string> list = new List<string>();

using (
       var cmd = new OleDbCommand(string.Format("slx_dbids('{0}', {1})", table, count), 
       connection)
)
{

   var r = cmd.ExecuteReader();

   while (r.Read())
   {
      list.Add(r.GetString(0));
   }

    r.Close();
 }

return list;

Now within the SalesLogix web client infrastructure it is a actually easier if you know where to look.

The framework exposes a service – SalesLogixEntityKeyGenerator. You can get access to this service using the following code;

SalesLogixEntityKeyGenerator generator = 
ApplicationContext.Current.Services.Get<SalesLogixEntityKeyGenerator>(false);

 

Once you have access to the generator it its very easy to get a set of keys;

List<string> keys = new List<string>(generator.GenerateIds(typeof(IHistory), 1));

 

There you have it.

Leave a Reply