The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Problem with GetByMethod DataGrid
Posted: 28 Jul 09 2:04 PM
|
I have found allot of related posts on the IQueryable and IExpressionFactory uses, but I can't seem to find what is specificly wrong with this code. I'm trying to return an IList to a datagrid that contains a list of TicketActivities. Here is the code....
#region Usings using System; using Sage.Entity.Interfaces; //using Sage.Form.Interfaces; using Sage.Platform.Repository; using Sage.Platform; using System.Collections.Generic; #endregion Usings
namespace Sage.BusinessRules.CodeSnippets { public static partial class TicketBusinessRules { public static void GetWorkPerformedStep( ITicket ticket, out IList result) { IRepository repository = EntityFactory.GetRepository(); IQueryable qry = (IQueryable)repository; IExpressionFactory ef = qry.GetExpressionFactory(); result = qry.CreateCriteria() .Add(ef.Eq("TicketId", ticket.Id.ToString())) .Add(ef.Eq("ActivityTypeCode", "Work Performed")) .List(); } } }
The error that gets returned is... "could not resolve property: TicketId of: Sage.SalesLogix.Entities.TicketActivity" ...I know that this usualy means that there is a Reference problem, but I can't find anything missing from my Usings, and the Codesnippet XML seems to have all of the needed references. Here is the Codesnippet.xml References....
%BASEBUILDPATH%\assemblies\Sage.Platform.dll %BASEBUILDPATH%\assemblies\NHibernate.dll %BASEBUILDPATH%\assemblies\Sage.Platform.Application.dll %BASEBUILDPATH%\assemblies\Microsoft.Practices.ObjectBuilder.dll %BASEBUILDPATH%\assemblies\Sage.Platform.Configuration.dll %BASEBUILDPATH%\interfaces\bin\Sage.Entity.Interfaces.dll %BASEBUILDPATH%\formInterfaces\bin\Sage.Form.Interfaces.dll
I have no doubt that I'm missing somthing trivial in my code, but I'm at a loss... 
Thanks! |
|
|
|
Re: Problem with GetByMethod DataGrid
Posted: 28 Jul 09 2:43 PM
|
Jeremy, Set the return type of your method to 'object' instead of 'IList'. That is likely your problem. Note you'll have to type it in as it's not available in the list. |
|
|
|
Re: Problem with GetByMethod DataGrid
Posted: 28 Jul 09 2:47 PM
|
The TicketActivity does not expose a TicketId property.
You may need to change that criteria to something like this: .Add(ef.Eq("Ticket", ticket)); |
|
|
|
Re: Problem with GetByMethod DataGrid
Posted: 28 Jul 09 2:50 PM
|
Originally posted by Mike LaSpina
Jeremy, Set the return type of your method to 'object' instead of 'IList'. That is likely your problem. Note you'll have to type it in as it's not available in the list. |
|
The error message that he is getting is clear, it cannot resolve the TicketId Property because the TicketActivity doesn't expose such property.
|
|
|
| |
|
Re: Problem with GetByMethod DataGrid
Posted: 28 Jul 09 3:03 PM
|
Agree, but the error message isn't for the TicketActivity.Id but rather for TicketActivity.TicketId. The Ticket Activity does not expose a TicketID property, but rather a Ticket.
Thus my solution was to change: .Add(ef.Eq("TicketId", ticket.Id.ToString()))
Into: .Add(ef.Eq("Ticket", ticket))
|
|
|
|
Re: Problem with GetByMethod DataGrid
Posted: 28 Jul 09 3:18 PM
|
Mike,
Same result. I assume that I needed to change the Return type in the business rule properties and the declaration of the return object in the code.
In case I missed something stupid on how I configured the DataSource, I have the properties set as follows...
Entity Type = TicketActivity Generate Member = True GetByMethod = GetWorkPerformed Is Collection = True Source = Ticket Use Smart Select = False |
|
|
|
Re: Problem with GetByMethod DataGrid
Posted: 28 Jul 09 3:21 PM
|
Ignore my last reply. You guys are fast! Let me try the object. I neglected to remember that Parent ID's are usualy exposed as Entity Relationships (like Owner instead of Seccodeid)...
I'll try this out... |
|
|
| |
|