Beringer Associates Technology Blog
One of our many specialties at Beringer is creating Microsoft Dynamics CRM customizations. We take pride in using the latest Microsoft technologies and software best practices to deliver solutions to our customers.
In this article I’d like to talk about LINQ and its uses in CRM. The Microsoft Documentation defines LINQ as the following:
Language-Integrated Query (LINQ) is an innovation introduced in Visual Studio 2008 and .NET Framework version 3.5 that bridges the gap between the world of objects and the world of data.
A little broad and grand, but what exactly do they mean? What is the world of objects? What is the world of data? The world of objects refers to the realm of Object-Oriented Programming, which in this example we will illustrate in C# (however it is important to note LINQ is widely supported in Visual Basic as well). The world of data is any type of data source (i.e.: SQL Database, XML documents, Web Services, etc.). Usually a developer will need to create queries to pull data from a source into the program that processes it. LINQ does the same operation, but allows for an easier integration of retrieved datasets into the workings of your software.
How exactly does this help your CRM customization? CRM is in essence a large database, so using LINQ should come naturally when manipulating data. Microsoft has plenty of code samples that utilize the power of LINQ at https://msdn.microsoft.com/en-us/library/gg328028.aspx. Let’s explore one of these samples and break down the different parts of a LINQ statement:
The keywords “from”, “join”, “where”, and “select” should make this code look very familiar to a SQL Query. Using the Service Context (svcContext), we can retrieve a portion of the AccountSet defined by our LINQ statement. We’re also able to “join” the SystemUserSet table to filter the AccountSet based on our filter (where owner.LastName != “Cannon”). This particular example is saying “Give me all Accounts where the Owner’s Last Name is not ‘Cannon’.”
You can also see that our “select” statement is built out like an object with two Attributes: Name and Address1_City. This object can be used freely in our Object-Oriented Programming Language of choice, which takes me back to Microsoft’s statement about LINQ at the beginning of the article. You can now access your collection of objects and perform operations on them. The retrieved information is already built out for your program to utilize.
Can we help you with your CRM implementation? Please feel free to contact us with any questions you may have.