Skip to main content

Posts

Showing posts from July, 2018

Dynamics 365 v9 Unit Testing and .NET Confusion

Recently while creating a plugin for Dynamics 365 v9, I ran into an issue trying to connect to CRM via the tooling connector in my unit test project.  The underlying problem was that the .NET version I was using in my unit test was 4.5.2.  This was preventing me from being able to connect to CRM to create my organization service.  I updated the .NET version on my unit test project to 4.6.1 and was then finally able to connect.  I will also add that I am using the latest nuget package version for Dynamics 365 v9. For consistence, I updated the plugin project I was working on to .NET 4.6.1.  Locally, everything was working great.  I was able to connect to CRM and make sure that all the methods I had written did what they where suppose to do using test driven development practices. Then when publishing my plugin via the latest version of the plugin registration tool, I received an error and could not publish my plugin.  The error was due to the .NET version of my plugin project not

Working With N:N Relationships in LINQ - Using Late Binding

Recently I had a requirement where I needed to get related records via a many-to-many (N:N) relationship in Dynamics 365 via a plugin in C#.  During my searching online, I kept coming to posts that involved using query expressions.  I wanted to do this with LINQ for consistence reasons and readability in my code.  I will also add that what I was doing was being done via Associate and Disassociate messages of the plugin.  I won't be reviewing that part of the plugin in this post, but I will just be focusing on the LINQ statement used to get the related records via the N:N relationship.  Here is the example code that I came up with: public List<Entity> GetRelatedRecords(Guid parentID, IOrganizationService service) { OrganizationServiceContext context = new OrganizationServiceContext(service); List<Entity> oProducts = (from r in context.CreateQuery(RELATIONSHIP_NAME) join eOne in context.CreateQuery(ENTITY_ONE_LO