I've the following code that works fine:
BeginRefresh(Library.Records.TaskList.GetTaskList);
This code is located the viewmodel and it works really well. My problem is that I don't know how to alter it to handle a criteria object (or parameters). Is there a way to create a criteria object and pass it into this mess? I apologize for the noob question - I'm still learning all this lambda stuff. Obviously, I'm using BXF here.
You can create a criteria object as an encapsulated class within TaskList.
Something like:
public class TaskList....
{
public class CriteriaForTaskByName : CriteriaBase<CriteriaForTaskByName>
{
public static readonly PropertyInfo<string> PhraseProperty =
RegisterProperty<string>(c => c.Name);
public string Name
{
get { return ReadProperty(NameProperty); }
set { LoadProperty(NameProperty, value); }
}
}
... other stuff....
}
// Add a GetTaskList using the criteria:
public static void GetTaskList(CriteriaForTaskByName criteria,
EventHandler<DataPortalResult<TaskList>> callback)
{
DataPortal.BeginFetch<TaskList>(criteria, callback);
}
// In Data Access region
private void DataPortal_Fetch(CriteriaForTaskByName criteria)
{
}
}
In your ViewModel use:
public FetchWithCriteria(string name)
{
TaskList.CriteriaForTaskByName =
new TaskList.CriteriaForTaskByName() { Name = name };
BeginRefresh( Library.Records.TaskList.GetTaskList(criteria) );
}
I get an error in the viewmodel on this line:
BeginRefresh( Library.Records.TaskList.GetTaskList(criteria) );
The error says: No overload method GetTaskList takes one argument. I think that is because GetTaskList, as you have it above, takes a criteria and a callback and I'm only passing in the criteria.
Okay, I found the answer. I replaced the problem line with this code:
BeginRefresh(callback => Library.Records.TaskList.GetTaskList(criteria, callback));
Yeah, you got it. Sorry about that mistake.
Copyright (c) Marimer LLC