Describe the bug
An exception "Object reference not set to an instance of an object" is thrown when using a particular fetchxml
To Reproduce
Execute the following code to reproduce the issue
[Microsoft.Xrm.Sdk.Client.EntityLogicalNameAttribute("solutioncomponent")]
public partial class SolutionComponent : Microsoft.Xrm.Sdk.Entity
{
public SolutionComponent() : base("solutioncomponent")
{
}
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("solutionid")]
public Microsoft.Xrm.Sdk.EntityReference SolutionId
{
get
{
return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("solutionid");
}
}
}
[Microsoft.Xrm.Sdk.Client.EntityLogicalNameAttribute("solutioncomponentdefinition")]
public class SolutionComponentDefinition : Microsoft.Xrm.Sdk.Entity
{
public SolutionComponentDefinition() : base("solutioncomponentdefinition")
{
}
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("name")]
public string Name
{
get
{
return this.GetAttributeValue<string>("name");
}
set
{
this.SetAttributeValue("name", value);
}
}
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("objecttypecode")]
public System.Nullable<int> ObjectTypeCode
{
get
{
return this.GetAttributeValue<System.Nullable<int>>("objecttypecode");
}
set
{
this.SetAttributeValue("objecttypecode", value);
}
}
}
[TestClass]
public sealed class Test1
{
public static IXrmFakedContext CreateXrmFakedContext()
{
var context = MiddlewareBuilder
.New()
.AddCrud()
.AddFakeMessageExecutors()
.AddFakeMessageExecutors(Assembly.GetAssembly(typeof(RetrieveVersionRequestExecutor)))
.UseCrud()
.UseMessages()
.SetLicense(FakeXrmEasyLicense.RPL_1_5)
.Build();
context.EnableProxyTypes(Assembly.GetExecutingAssembly());
return context;
}
[TestMethod]
public void TestNominal()
{
// Arrange
var context = CreateXrmFakedContext();
string fetchxml = @"
<fetch xmlns:generator='MarkMpn.SQL4CDS'>
<entity name='solutioncomponent'>
<attribute name='solutionid' />
<link-entity name='solutioncomponentdefinition' to='componenttype' from='objecttypecode' alias='solutioncomponentdefinition' link-type='outer'>
<attribute name='name' alias='solutioncomponentdefinitionname'/>
</link-entity>
<filter>
<condition attribute = 'name' entityname='solutioncomponentdefinition' operator='eq' value='AppElement'/>
</filter>
</entity>
</fetch>
";
context.GetOrganizationService().RetrieveMultiple(new FetchExpression(fetchxml));
}
}
Expected behavior
No exception, and get the result
Version
FakeXrmEasy.v9 3.6.0
Notes
The problem is here :

When we enter in the method, attributeName="name". But after substring, attributeName is empty
I think a code like this can solve the issue :

Describe the bug
An exception "Object reference not set to an instance of an object" is thrown when using a particular fetchxml
To Reproduce
Execute the following code to reproduce the issue
Expected behavior
No exception, and get the result
Version
FakeXrmEasy.v9 3.6.0
Notes
The problem is here :
When we enter in the method, attributeName="name". But after substring, attributeName is empty
I think a code like this can solve the issue :