[New post] Dynamics CRM: Proving Auto Number Data Type Is Legit!
temmyraharjo posted: " I just saw Nishant Rana's post about the auto-number data type that you can check here. And to be honest, I just knew about it and felt intrigued to test it. My expectation was pretty low about this data type (to handle lots of requests and result to dup"
I just saw Nishant Rana's post about the auto-number data type that you can check here. And to be honest, I just knew about it and felt intrigued to test it. My expectation was pretty low about this data type (to handle lots of requests and result to duplicate numbers in the end). TL;DR (Too Long; Didn't Read), IT'S NOT!
For the testing purpose, I created the below Table with auto-number attribute with the name new_autonumber:
For generating the entities inside the c# code, I used the below code:
using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Web.Configuration; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Tooling.Connector; namespace CrmCheck { class Program { static void Main(string[] args) { var connectionString = WebConfigurationManager.AppSettings["connectionString"]; var client = new CrmServiceClient(connectionString); Console.WriteLine($"Connected to {client.OrganizationDetail.UniqueName}.."); var tasks = new List<Task>(); for (int i = 0; i < 100; i++) { var number = $"Thread-{i.ToString().PadLeft(5, '0')}"; tasks.Add(Task.Factory.StartNew(() => { var id = Guid.NewGuid(); var entity = new Entity("new_test"); entity["new_name"] = number; Console.WriteLine($"Number {number}: {client.Create(entity)}"); })); } Task.WaitAll(tasks.ToArray()); Console.ReadKey(); } } }
The code above, as you can see is using multithreading to create 100 new_test data per run. To make it more complex, I run 4 instances of the exe:
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.