This is a migrated thread and some comments may be shown as answers.

List<T> as Queryparameter.Value

2 Answers 44 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Holger
Top achievements
Rank 1
Holger asked on 10 May 2011, 08:09 AM
Hy all,
we are currently evaluating the Telerik Silverlight Suite and I have a question.
Actually I am still learning Silverlight and all of my code is just for Test purpose and to see how things are going.
Now my problem:

I have a search page with three check boxes on. Each checkbox stands for a status value (open, closed etc.).
If it is checked, I want to include this rows in my results. All is fully functional, if I make my calls to the Context manually.

In second step Iwanted to use the Domaindatasource, but exclusively in code behind.

This is my Query Function:

/// <summary>
/// Gib Suchergebnisse zurück
/// </summary>
/// <param name="FSG1">Objektnummer</param>
/// <param name="Status">Liste der Stati, nach denen gesucht werden soll</param>
/// <returns>Ergebnisse der IQueryable</returns>
public IQueryable<FPT> GetFPTbyWhere(string FSG1, List<string> Status)
{
    IQueryable<FPT> result = this.ObjectContext.FPT.Include("FSG").Include("FPTA").OrderBy(p => p.FSG1);
 
    if (FSG1 != string.Empty)
    {
        result = result.Where(p => p.FSG1.Contains(FSG1));
    }
 
    if (Status != null && Status.Count > 0)
    {
        result = result.Where(p => Status.Contains(p.FPT104));
    }
 
    return result;
}

As you can see, I make a lambda expression against a List of strings (they are actually the values from the check boxes.
But, when I try to use the Queryparameter with List<string> as a Parameter value, it is always null in the function above.

Code for RadDomaindataSource:

List<string> Status = new List<string>();
 
if (cbOffen.IsChecked.Value)
{
    Status.Add("0");
}
if (cbInAuftrag.IsChecked.Value)
{
    Status.Add("1");
}
if (cbErledigt.IsChecked.Value)
{
    Status.Add("2");
}
 
if (dsFPT.QueryName == "GetFPTbyWhere")
{
    dsFPT.QueryParameters.Single(p => p.ParameterName == "FSG1").Value = txtObjektnummer.Text;
    dsFPT.QueryParameters.Single(p => p.ParameterName == "Status").Value = Status;
}
else
{
    dsFPT.BeginInit();
    Telerik.Windows.Controls.QueryParameter param1 = new Telerik.Windows.Controls.QueryParameter();
    param1.ParameterName = "FSG1";
    param1.Value = txtObjektnummer.Text;
 
    Telerik.Windows.Controls.QueryParameter param2 = new Telerik.Windows.Controls.QueryParameter();
    param2.ParameterName = "Status";
    param2.Value = Status;
 
    dsFPT.QueryParameters.Add(param1);
    dsFPT.QueryParameters.Add(param2);
    dsFPT.QueryName = "GetFPTbyWhere";
    dsFPT.EndInit();
}
 
dsFPT.Load();


Anyone a hint?

Is it not possible to use List objects as Query Parameter?

Many thanks in advance.

Holger

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 10 May 2011, 09:00 AM
Hi Holger,

Your question is not related to Telerik controls in any way. Please post questions like this on the WCF RIA Services forum where they belong.

Anyway, here is a what a quick forum search returns:


I hope this helps.

All the best,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Holger
Top achievements
Rank 1
answered on 10 May 2011, 09:11 AM
Hy Ross,

-.-' I searched yesterday for hours in your forum and other fourms and didnt find anything related to this. Dont know why.
Sorry, if it was not related to Telerik and many thanks for your answer and support.

Kind regards,

Holger
Tags
DomainDataSource
Asked by
Holger
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Holger
Top achievements
Rank 1
Share this question
or