I want to get list of list of solution displayed in DropDown in windows application.
So, to get the list of solutions I have written below QueryExpression
and added a filter for the same:
public EntityCollection GetSolutions(IOrganizationService service, string solutionUniqueNameLike)
{
QueryExpression querySampleSolution = new QueryExpression
{
EntityName = "solution",
ColumnSet = new ColumnSet(new string[] { "publisherid", "installedon", "version", "versionnumber", "friendlyname", "ismanaged", "uniquename" }),
Criteria = new FilterExpression()
};
querySampleSolution.Criteria.AddCondition("uniquename".ToLower(), ConditionOperator.Like, "*" + solutionUniqueNameLike.ToLower() + "*");
var solutions = service.RetrieveMultiple(querySampleSolution);
//var filteredSolutions = solutions.Entities.Where(e => (e.Attributes.Contains("uniquename")) && (e.Attributes["uniquename"].ToString().ToLower() == "*" + solutionUniqueNameLike + "*"));
if (solutions?.Entities?.Count > 0)
{
return solutions;
}
return null;
}
But it is returning the 0 entities in the result.
I have also tried to search in the all solutions by using LINQ as added in the commented line of code above. But getting NULL
in there.
EDIT 1: When I tried using Contains
instead of `Like condition, it is throwing an error as below:
System.ServiceModel.FaultException
1 HResult=0x80131501 Message= Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql ErrorCode: -2146232060 Sql Number: 7601 Source=mscorlib
2 action) at Microsoft.Xrm.Client.Services.OrganizationService.RetrieveMultiple(QueryBase query) at TestProjectForCRM.Program.Main(String[] args) in C:\Users\pratik.soni\source\repos\TestProjectForCRM\TestProjectForCRM\Program.cs:line 37
StackTrace: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple(QueryBase query) at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultipleCore(QueryBase query) at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultiple(QueryBase query) at Microsoft.Xrm.Client.Services.OrganizationService.<>c__DisplayClass22.<RetrieveMultiple>b__21(IOrganizationService s) at Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func
Not sure what I'm missing here.
I want to add why you are seeing the below error:
System.ServiceModel.FaultException1 HResult=0x80131501 Message=
Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql
ErrorCode: -2146232060 Sql Number: 7601
The piece which will be useful is Sql Number: 7601, the Database engine Events & Errors says Cannot use a CONTAINS or FREETEXT predicate on %S_MSG '%.*ls' because it is not full-text indexed.
Refer my blog on how to crack this error message.
User contributions licensed under CC BY-SA 3.0