User Review( votes)
While using Fake XRM Easy for Plug-in or Workflow unit testing, there could be situations that could arise where we need to use fetchXML to retrieve some records. While it works for most of the time, it can be tricky while working with some attributes statecode for starters.
In the above fetchXML, “<condition attribute=”statecode” operator=”eq” value=”0″ />” will throw the error ‘When using arithmetic values in Fetch a ProxyTypesAssembly must be used in order to know which types to cast values to.’ as shown in the below screenshot:
Note: Once you open up the Early Bound Generator, you need to click on Create All button to generate class files for Entities, Actions, and Optionsets. Otherwise, based on your requirement you can decide which one you need to generate.
After the process is complete, put those three files (Actions.cs, Entities.cs, Optionsets.cs) in the project you are working and change the namespace of these files to align with your project’s. For a cleaner folder structure, add a folder named Helper or of the same tone in your project and put these files in it.
After you’ve declared the context, you need to add proxy type assembly to your faked context, as shown in the screenshot below:
Note: For feasibility, use the line of code given below.
context.ProxyTypesAssembly = Assembly.GetExecutingAssembly();
Following the above approach, you will be able to use FetchXML to retrieve data without getting ‘When using arithmetic values in Fetch a ProxyTypesAssembly must be used in order to know which types to cast values to.’ error.