VB language has some advantage and some restriction comparing C#. Some advantage I enumerate in page Difference between VB and C#, but in this page I want to enumerate interesting and unexpected restriction of VB compiler.
First interesting restriction I has describe in page Generic VB.NET function for loading ExcelFile to DataBase (EF6 CodeFirst) with Reflection and avoiding Linq-to-Entity Linq.Expressions (use Linq-to-Object IEnumerable) - it is a forbidden onplace declaration BYREF in delegate definition. To support BYREF transfer parameters you must obviously declare delegate in separate string and ref to delegate in parameters.
Second unexpected restriction is compilation of lambda expression. There is a best list of restriction of lambda expressing in VB.NET - vb-net-statement-lambdas-cannot-be-converted-to-expression-trees.Below you can see an integerstion example of this restriction.
In this code fragment I reorder a database and I define in one table key to another table.
This is a way to provide this link (this is part of data import process).
And in some moments of my algorithm I want to reorder data, but not directly in one table, on the related table. This is not workable statement with restriction of VB.NET compiler.
And this is workable code.
55: db1 = New MgtlDbContext
57: OrderBy(Function(X) db1.CompanyNames.Where(Function(Y) Y.I = X.ToCompanyName).FirstOrDefault.CompanyNameInCodeWorthy).
58: ThenBy(Function(X) X.Location).
59: ThenBy(Function(X) X.ShiftDate).
60: ThenBy(Function(X) X.DocketID).
62: Select(Function(X, Index)
63: 'Debug.Print(Index & ":" & X.I)
64: X.OrderBy = Index
65: Return X
66: End Function).ToList
Most incredible and incomprehensible in this case than multiline Lambda in allow in select clause, but forbidden in OrderBy clause.
|<SITEMAP> <MVC> <ASP> <NET> <DATA> <KIOSK> <FLEX> <SQL> <NOTES> <LINUX> <MONO> <FREEWARE> <DOCS> <ENG> <CHAT ME> <ABOUT ME> < THANKS ME>|