{"id":26299,"date":"2021-01-06T12:50:41","date_gmt":"2021-01-06T12:50:41","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=26299"},"modified":"2021-01-07T04:52:57","modified_gmt":"2021-01-07T04:52:57","slug":"how-to-solve-when-using-arithmetic-values-in-fetch-a-proxytypesassembly-must-be-used-in-order-to-know-which-types-to-cast-values-to-while-using-fake-xrm-easy","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2021\/01\/how-to-solve-when-using-arithmetic-values-in-fetch-a-proxytypesassembly-must-be-used-in-order-to-know-which-types-to-cast-values-to-while-using-fake-xrm-easy\/","title":{"rendered":"How to solve \u201cWhen using arithmetic values in Fetch a ProxyTypesAssembly must be used in order to know which types to cast values to\u201d while using Fake XRM Easy"},"content":{"rendered":"<h1>Introduction<\/h1>\n<p style=\"text-align: justify;\">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.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-1.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26300 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-1.png\" alt=\"solve arising error while using Fake XRM Easy\" width=\"894\" height=\"291\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-1.png 894w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-1-300x98.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-1-768x250.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-1-660x215.png 660w\" sizes=\"(max-width: 894px) 100vw, 894px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">In the above fetchXML, \u201c&lt;condition attribute=&#8221;statecode&#8221; operator=&#8221;eq&#8221; value=&#8221;0&#8243; \/&gt;\u201d will throw the error \u2018When using arithmetic values in Fetch a ProxyTypesAssembly must be used in order to know which types to cast values to.\u2019 as shown in the below screenshot:<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/error-2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26301 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/error-2.png\" alt=\"error\" width=\"821\" height=\"381\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/error-2.png 821w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/error-2-300x139.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/error-2-768x356.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/error-2-660x306.png 660w\" sizes=\"(max-width: 821px) 100vw, 821px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">To overcome this, we need to generate Early Bound. For that, we will be using the <a href=\"https:\/\/www.xrmtoolbox.com\/plugins\/DLaB.Xrm.EarlyBoundGenerator\/\" target=\"_blank\" rel=\"noopener noreferrer\">Early Bound Generator<\/a> plugin of <a href=\"https:\/\/www.xrmtoolbox.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">XrmToolBox<\/a>.<\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-3.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26306 size-large\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-3-1024x488.png\" alt=\"solve arising error while using Fake XRM Easy\" width=\"665\" height=\"317\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-3-1024x488.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-3-300x143.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-3-768x366.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-3-660x315.png 660w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/solve-arising-error-while-using-Fake-XRM-Easy-3.png 1152w\" sizes=\"(max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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\u2019s. For a cleaner folder structure, add a folder named Helper or of the same tone in your project and put these files in it.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/add-helper-folder-4.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26305 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/add-helper-folder-4.png\" alt=\"add helper folder\" width=\"326\" height=\"202\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/add-helper-folder-4.png 326w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/add-helper-folder-4-300x186.png 300w\" sizes=\"(max-width: 326px) 100vw, 326px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">After you\u2019ve declared the context, you need to add proxy type assembly to your faked context, as shown in the screenshot below:<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/add-proxy-type-assembly-5.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26304 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/add-proxy-type-assembly-5.png\" alt=\"add proxy type assembly\" width=\"578\" height=\"88\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/add-proxy-type-assembly-5.png 578w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/add-proxy-type-assembly-5-300x46.png 300w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/><\/a><\/p>\n<p>Note: For feasibility, use the line of code given below.<\/p>\n<p>context.ProxyTypesAssembly = Assembly.GetExecutingAssembly();<\/p>\n<h2>Conclusion<\/h2>\n<p style=\"text-align: justify;\">Following the above approach, you will be able to use FetchXML to retrieve data without getting \u2018When using arithmetic values in Fetch a ProxyTypesAssembly must be used in order to know which types to cast values to.\u2019 error.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/productivity-apps\/click-2-clone-microsoft-dynamics-crm-records\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26309 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/c2c.jpg\" alt=\"click2clone\" width=\"800\" height=\"200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/c2c.jpg 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/c2c-300x75.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/c2c-768x192.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/c2c-660x165.jpg 660w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction 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, \u201c&lt;condition attribute=&#8221;statecode&#8221;\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2021\/01\/how-to-solve-when-using-arithmetic-values-in-fetch-a-proxytypesassembly-must-be-used-in-order-to-know-which-types-to-cast-values-to-while-using-fake-xrm-easy\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[16,19],"tags":[2113,2112,795],"class_list":["post-26299","post","type-post","status-publish","format-standard","hentry","category-dynamics-365","category-dynamics-crm","tag-early-bound-generator","tag-fake-xrm-easy","tag-fetchxml"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/26299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=26299"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/26299\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=26299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=26299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=26299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}