2011-08-16 6 views
0

SharepointでSilverlightアプリケーションを使用してWCFサービスを使用しようとしています。SilverlightアプリケーションでLINQクエリを使用しているエラー

リストからすべてのデータをグリッドに表示します。何とかそれはエラーを投げている。

ラムダ式をデリゲート型ではないため 'system.Delegate'と入力できません。ジェネリック型「system.collections.generic.ienumerable」を使用して

SLprojectsCRUD2010WCF.sharepointservice.list1itemが」タイプであるが、変数のように使用されている1型の引数​​が必要です。

どのように解決できますか?あなたのソースコードが適切にフォーマットされるまで

private SharePointService.SkinnyBlondeDataContext _context; 

public MainPage() 
{ 
    InitializeComponent(); 
    this.Loaded += new RoutedEventHandler(LayoutRoot_Loaded); 
} 

private void ShowProjects() 
{ 
    // Declare the LINQ query 
    var projectsQuery = (from p in _context.Tasks 
          select p) as DataServiceQuery<SharePointService.TasksItem>; 
    // Execute the LINQ query 
    projectsQuery.BeginExecute((IAsyncResult asyncResult) => Dispatcher.BeginInvoke(() => 
    {    // Runs in the UI thread 
     // EndExecute returns 
     IEnumerable <TasksItem> this.dataGridProjects.ItemsSource = projectsQuery.EndExecute(asyncResult).ToList(); 
    }), projectsQuery); 
} 

private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) 
{ 
    // Get the context 
    _context = new SharePointService.SkinnyBlondeDataContext(
       new Uri("http://vanir0269/_vti_bin/listdata.svc", UriKind.Absolute)); 
    ShowProjects(); 
} 
+2

あなたの投稿をフォーマットしてください。私は普通あなたのためにやっていますが、それは恐ろしい*状態にあり、おそらくソースコードからより簡単に行うことができます。 –

答えて

1

LINQの問題が何であるかを見るために苦痛になるだろうが、ラムダ式の問題は簡単です:Dispatcher.BeginInvokeDelegateかかり、ラムダ式はに変換することができます特定のデリゲートタイプ。これは簡単に修正できます:

projectsQuery.BeginExecute((IAsyncResult asyncResult) => { 
    Action action =() => { 
     // Code in here 
    }; 
    Dispatcher.BeginInvoke(action, null); 
}); 
関連する問題