Instantiating LinqMetaData

Posts   
 
    
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 27-Sep-2008 01:38:48   

Okay, I give up!

Where does LinqMetaData live so I can instantiate one?

dim meta as new LinqMetaData

gives error: type linqmetadata is not defined.

Imports SD.LLBLGen.Pro.LinqSupportClasses is there

Linq folder under generated code is not.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Sep-2008 02:56:43   

Hi Terry,

To get started with Linq to LLBLGen Pro:

  1. Generate code for .NET 3.5 and for Adapter or SelfServicing.
  2. Your VS.NET project should reference the SD.LLBLGen.Pro.LinqSupportClasses.NET35.dll as well as the generated code project(s) and the SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll.

Did you generate for .NET 3.5 platform?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 27-Sep-2008 10:48:17   

Indeed, if you don't specify .net 3.5, the linqmetadata class isn't there obviously.

Frans Bouma | Lead developer LLBLGen Pro
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 27-Sep-2008 20:26:10   

Yeah, well the things obvious to you aren't here simple_smile

I can get EDM with linq going with MS's instructions, but I'm still stuck getting hello world going here for linq2llbl.

Choosing 3.5 in generation got LinqMetaData instantiated, but with this syntax I get error instead of result.

  Dim metaData As New LinqMetaData
  Dim q = From c In metaData.Customer Select c

Error is on metaData.customer saying: expression of type ...customerentity is not queryable, make sure you are not missing an assembly reference or a namespace import

I see the 3 SD.L.P... references and my project reference in project properties references.

here are the import statements: Imports NwmDal Imports NwmDal.CollectionClasses Imports NwmDal.EntityClasses Imports NwmDal.helperclasses Imports NwmDal.Linq Imports SD.LLBLGen.Pro.LinqSupportClasses Imports SD.LLBLGen.Pro.ORMSupportClasses Imports System.Collections.Generic Imports Microsoft.Reporting.WebForms

What's next? simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 27-Sep-2008 21:57:05   

Are you sure you have the latest templates, there was a bug in the vb.net templates in linqmetadata. (please download the latest v2.6 build from the customer area so you also get the latest linq support classes)

Also, for things to get started, please try to generate in a new empty folder so all files get overwritten. The error you get is rather strange though. LinqMetaData.<entityName> returns a DataSource(Of <entityName>) instance which does implement IQueryable(Of <entityName>).

Frans Bouma | Lead developer LLBLGen Pro
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 28-Sep-2008 01:15:25   

I logged into customer area and downloaded the full version.

I next uninstalled llblgenpro last version and installed the new version.

I got an error on writing the llblgenpro.chm file probably because the uninstall didn't take the help file out???

Then I deleted the last generation of code.

Regenerated with the new version 9/16 date, and after removing project and then adding it back in, reesatblishing reference to project, I see that the same error as above is there.

I hit F5 and failed with the one error.

This is a web project that has recently been converted to 2008 and 3.5 and when I did that there were problems with the web.config file in that the httphandlers for ajax were not copied into there. Just in case something else could be missing.

The basic statement works if put into a new web project, but not in the converted project. So the difference might be the web.config.

I compared the 2 web.configs and the namespace on the converted one was missing system.linq.

After changing that, the error went away. compiling says there are compile errors, but none listed, so next time I choose yes contine with last successful build to see if I can get further info that way. Project comes to expected login screen and I navigate to billing where my test is and get:

Server Error in '/nwm' Application.

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30205: End of statement expected.

Source Error:

Line 62: 'custs.GetMulti(aFilter, 0, aSort) Line 63: Dim metaData As New LinqMetaData Line 64: Dim custs = From c In metaData.Customer Select c Line 65: customers.Items.Clear() Line 66: customers.Items.Add(New ListItem("Select", "0"))

Source File: C:\Websites\nwm\billing.aspx.vb Line: 64

I closed Visual Studio and started back up, but I get the same results.

Any Ideas?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Sep-2008 22:34:22   

tvoss wrote:

This is a web project that has recently been converted to 2008 and 3.5 and when....

The basic statement works if put into a new web project, but not in the converted project. So the difference might be the web.config.

From this http://forums.asp.net/t/1110780.aspx seems that this code on your web.config should fix the problem:

<system.codedom>
   <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/warnaserror-">
         <providerOption name="CompilerVersion" value="v3.5"/>
      </compiler>
    
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/optioninfer+">
         <providerOption name="CompilerVersion" value="v3.5"/>
      </compiler>
   </compilers>
</system.codedom>
David Elizondo | LLBLGen Support Team
tvoss avatar
tvoss
User
Posts: 192
Joined: 07-Dec-2003
# Posted on: 29-Sep-2008 04:47:50   

This solved the problem.

The new web project had that code and the converted one didn't.

So the reason to build a linq2llbl is: 2 lines of code versus 6 and a std that works many places, and 2 properties instead of all for less memory? (too bad it is not strongly typed)

1 'Dim aFilter As New PredicateExpression 2 'aFilter.Add(CustomerFields.Active = True) 3 'Dim aSort As New SortExpression 4 'aSort.Add(New SortClause(CustomerFields.Name, SortOperator.Ascending)) 5 'Dim custs As New CustomerCollection 6 'custs.GetMulti(aFilter, 0, aSort)

1 Dim db As New LinqMetaData 2 Dim custs = From c In db.Customer Where c.Active = True _ Order By c.Name Select c.Name, c.Id

  customers.Items.Clear()
  customers.Items.Add(New ListItem("Select", "0"))
  For Each cust As Object In custs
    customers.Items.Add(New ListItem(cust.Name.Trim, cust.Id.ToString))
  Next

Thanks,

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 29-Sep-2008 11:16:16   

tvoss wrote:

This solved the problem.

The new web project had that code and the converted one didn't.

So the reason to build a linq2llbl is: 2 lines of code versus 6 and a std that works many places, and 2 properties instead of all for less memory? (too bad it is not strongly typed)

The memory consumption isn't really a point, as the Linq query is converted to predicates, relationcollections, etc. and calls under the hood GetMulti.

1 'Dim aFilter As New PredicateExpression 2 'aFilter.Add(CustomerFields.Active = True) 3 'Dim aSort As New SortExpression 4 'aSort.Add(New SortClause(CustomerFields.Name, SortOperator.Ascending)) 5 'Dim custs As New CustomerCollection 6 'custs.GetMulti(aFilter, 0, aSort)

1 Dim db As New LinqMetaData 2 Dim custs = From c In db.Customer Where c.Active = True _ Order By c.Name Select c.Name, c.Id

  customers.Items.Clear()
  customers.Items.Add(New ListItem("Select", "0"))
  For Each cust As Object In custs
    customers.Items.Add(New ListItem(cust.Name.Trim, cust.Id.ToString))
  Next

Thanks,

The main reason to build Linq to LLBLGen pro is indeed the standard: more and more people will know the language constructs and can build queries right out of the box. Added to that, you can create db function calls easier, have hierarchical projections in lesser code and fill anonymous types with data.

Btw, the anonymous type IS strongly typed wink That's a big advantage over a datatable with non-strongly typed columns to which you project a resultset to. simple_smile

Frans Bouma | Lead developer LLBLGen Pro