LINQ Questions, Some Answers

::: {.Section1} [In comments, Mark Mehelis asked some good questions re. LINQ: ]{style="font-size:10.0pt; font-family:Arial"}

  • [As far as I can tell [the syntax between VB and C# is not the same]{style="font-weight:bold"}. Do you know why this is? Would it not be better to have this be consistent accross the languages?]{style="font-size:10.0pt;font-family:Arial"}

[The syntax does indeed vary between languages. A consistent query [language ]{style="font-weight:bold"}would definitely have been easier to learn, but what LINQ provides is a set of consistent query [operators]{style="font-weight:bold"} that can be incorporated into languages in whatever way the language designer sees fit. This makes LINQ slightly less teachable (it will vary from language to language) but perhaps more appealing to language designers, since they aren’t forced to accept a query language that differs from their own language design philosophy. Vick (VB) is emphasizing familiarity and a SQL-like syntax, Hejlsberg (C#) is emphasizing functional-style programming forms. This is also a good place to point out that languages can use the underlying APIs even if they do not implement language extensions. []{.underline} ]{style="font-size:10.0pt; font-family:Arial"}

  • [Is there some way to have all your [LINQ based access through a repository of some type]{style="font-weight:bold"}. It would be to easy to pepper queries throughout your code making it a string pulling excersize when your application gained some size.]{style="font-size:10.0pt;font-family:Arial"}

[This is an interesting idea. I haven’t worked with actual LINQ code enough to actually wrap my head around how it affects coupling and cohesion, so I don’t know. We don’t yet know what patterns are productive in LINQ-using programs. Obviously, you could put all your queries in a single class behind a façade and even put that class into its own namespace / assembly. Would that be a good idea? Not sure.]{style="font-size:10.0pt; font-family:Arial"}

  • [Also what happens when the [underlying data structure in the DB changes?]{style="font-weight:bold"} Must you re-compile your code? recreate your classes and then change your LINQ queries?]{style="font-size:10.0pt;font-family:Arial"}

[You definitely should [not]{style="font-style:italic"} have to recompile on a DB change, you almost certainly do if you’re querying objects. ]{style="font-size:10.0pt; font-family:Arial"}

[ ]{style="font-size:10.0pt;font-family:Arial"}

[ ]{style="font-size:10.0pt; font-family:Arial"}

:::