Closed don-matese closed 7 years ago
Hi @don-matese ,
Just checked in some code to reproduce your issue and both queries run fine. This is normally related to the way crmsvcutil generates the early bound types, cause there might be difference across different versions of the crmsvcutil. For instance, closed issue #114 was exactly the same thing, a crmsvcutil was generating enums as nullable ints, instead of the previous tested cases with Enums or OptionSetValue for example.
Could you post what types do you have in your generated classes for the properties involved in the queries above?
This is the applied fix for #114, could you add a new case there maybe with your specific types, and submit a PR?
Cheers
Hi Jordi,
They are all EntityReference fields declared as follows
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("primarycontactid")]
public Microsoft.Xrm.Client.CrmEntityReference PrimaryContactId
{
get
{
return
this.GetAttributeValue
this.SetAttributeValue
On 2 February 2017 at 09:06, Jordi notifications@github.com wrote:
Hi @don-matese https://github.com/don-matese ,
Just checked in some code to reproduce your issue and both queries run fine. This is normally related to the way crmsvcutil generates the early bound types, cause there might be difference across different versions of the crmsvcutil. For instance, closed issue #114 https://github.com/jordimontana82/fake-xrm-easy/issues/114 was exactly the same thing, a crmsvcutil was generating enums as nullable ints, instead of the previous tested cases with Enums or OptionSetValue for example.
Could you post what types do you have in your generated classes for the properties involved in the queries above?
Cheers
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jordimontana82/fake-xrm-easy/issues/116#issuecomment-276903295, or mute the thread https://github.com/notifications/unsubscribe-auth/ABl8KHx-k1RhKbmCtVTtR5l_Ky-thLTHks5rYZyDgaJpZM4L0El_ .
Just one thing then... I replaced your attributenames definitions by lowercase as the AttributeNames wasn't in your sample, maybe you aren't using lowercase names? Are you on latest version 1.20.1? Cause those examples run fine without exceptions :)
Mmm runs fine locally, fails on appveyor, but probably related to referenced SDK version. Will double check again
I have the latest version, given one of the queries works and the other doesn't I think I am more inclined to believe either the code I inherited is flawed (likely) or the structure of the query is unexpected in the QueryExpression handler in FakeXrmEasy. Either way, I suspect its the way the Query in CreateBrokenTestQuery is constructed thats at the root of the issue - thanks for your time on this though.
Mauro
On 2 February 2017 at 09:20, Jordi notifications@github.com wrote:
Mmm runs fine locally, fails on appveyor, but probably related to referenced SDK version. Will double check again
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jordimontana82/fake-xrm-easy/issues/116#issuecomment-276906280, or mute the thread https://github.com/notifications/unsubscribe-auth/ABl8KHITAOPX-dMJjDRP3TWGf9PwMUuCks5rYZ_zgaJpZM4L0El_ .
Apologies Jordi
Having looked at the code a bit more closely, while the Attributes I am
filtering on are indeed EntityReferences, other fields are declared as
nullable
Your entity code for example has this attribute in Account
/// <summary>
/// Select a category to indicate whether the customer account is
standard or preferred. ///
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountcategorycode")]
public Microsoft.Xrm.Sdk.OptionSetValue AccountCategoryCode
{
get
{
return
this.GetAttributeValue
Whereas mine does the following
/// <summary>
/// Drop-down list for selecting the category of the account.
/// </summary>
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountcategorycode")]
public System.Nullable
this.SetAttributeValue
Your code was generated using CrmSvcUtil [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "7.0.0000.3543")] mine was [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "5.0.9688.1046")]
Does your fix then mean I need to recompile my Entities Classes using a newer CrmSvcUtil?
On 2 February 2017 at 09:26, Mauro Masucci mauro.masucci@gmail.com wrote:
I have the latest version, given one of the queries works and the other doesn't I think I am more inclined to believe either the code I inherited is flawed (likely) or the structure of the query is unexpected in the QueryExpression handler in FakeXrmEasy. Either way, I suspect its the way the Query in CreateBrokenTestQuery is constructed thats at the root of the issue - thanks for your time on this though.
Mauro
On 2 February 2017 at 09:20, Jordi notifications@github.com wrote:
Mmm runs fine locally, fails on appveyor, but probably related to referenced SDK version. Will double check again
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jordimontana82/fake-xrm-easy/issues/116#issuecomment-276906280, or mute the thread https://github.com/notifications/unsubscribe-auth/ABl8KHITAOPX-dMJjDRP3TWGf9PwMUuCks5rYZ_zgaJpZM4L0El_ .
Wow! that looks like a bug in the crmsvcutil version you are using (which is highly likely, for instance, latest developer toolkit for 365 beta generates types which don't even build ).
It is weird that one property should be retrieved as a Nullable
Issue #114 was sorted with this version: 5.0.9690.2165
Could you try with that one?
Hi Mauro, did that work with crmsvcutil from latest 2011 SDK?
Hi Mauro, closing this one. If you still are having issues please reopen it.
When testing a method from a third party I get the error "specified cast is not valid" . In all honesty I am not sure if the problem is the query or the FakeXrmEasy test.
you can also read more here http://stackoverflow.com/questions/41978580/specified-cast-invalid
Included code below