Convert Lambda from C# to VB.NET
所有的# translate this C和VB.NET为lambda表达式?P></
1 | query.ExecuteAsync(op => op.Results.ForEach(Employees.Add)); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Collections.ObjectModel; using IdeaBlade.Core; using IdeaBlade.EntityModel; </p> <p> namespace SimpleSteps { public class MainPageViewModel { public MainPageViewModel() { Employees = new ObservableCollection(); var mgr = new NorthwindIBEntities(); var query = mgr.Employees; query.ExecuteAsync(op => op.Results.ForEach(Employees.Add)); } </p> [cc lang="csharp"] public ObservableCollection<Employee> Employees { get; private set; } } |
}P></
// Execute the query asynchronously. IdeaBlade.EntityModel.EntityManager.ExecuteQueryAsync()
//
// Parameters:
// query:
// This query
//
// Type parameters:
// T:
// Entity type returned
public static EntityQueryOperation
//
// Summary:
// Execute the query asynchronously. IdeaBlade.EntityModel.EntityManager.ExecuteQueryAsync()
//
// Parameters:
// query:
// This query
public static EntityQueryOperation ExecuteAsync(this IEntityQuery query);
//
// Summary:
// Execute the query asynchronously. IdeaBlade.EntityModel.EntityManager.ExecuteQueryAsync()
//
// Parameters:
// query:
// This query
//
// userCallback:
// Callback invoked when the query completes
//
// userState:
// Token to identify the query upon completion
//
// Type parameters:
// T:
// Entity type returned
//
// Remarks:
// Provide a userCallback if you want to be notified when the operation completes.
// The query results will be returned in the IdeaBlade.EntityModel.EntityQueriedEventArgs
// passed to the userCallback. Use the userState to uniquely identify this
// call.
public static EntityQueryOperation
//
// Summary:
// Execute the query asynchronously. IdeaBlade.EntityModel.EntityManager.ExecuteQueryAsync()
//
// Parameters:
// query:
// This query
//
// userCallback:
// Callback invoked when the query completes
//
// userState:
// Token to identify the query upon completion
//
// Remarks:
// Provide a userCallback if you want to be notified when the operation completes.
// The query results will be returned in the IdeaBlade.EntityModel.EntityQueriedEventArgs
// passed to the userCallback. Use the userState to uniquely identify this
// call.`
从2010年开始,vb10支持非功能lambda。
1 | query.ExecuteAsync(Sub(op) op.Results.ForEach(Employees.Add)) |
1 | query.ExecuteAsync(Function(op) op.Results.ForEach(Employees.Add)) |
您也可以在这里执行此操作:http://www.developerfusion.com/tools/convert/csharp-to-vb/
我找到了解决办法。
1 | query.ExecuteAsync.Results.ForEach(Sub(o) Employees.Add(o)) |
希望这对别人有帮助