Entity Framework 4.0 References

Posts   
 
    
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 21-Jul-2010 12:26:45   

Hi all,

It's been a while since I did any coding and I'm trying to get back up to speed... Wow things have moved on in the last 18 months!

I'm currently playing with LLBLGen 3.0 and have generated some Entity Framework 4.0 code. When I reference the generated project from another class library I seem to be missing something as I keep getting linq compile errors.

I'm sure there is something obvious that I am missing but here is the obvious stuff that I have done:

  • I have referenced the generated project from the class lib.
  • I have checked all lib assembly references are the same as the generated project.
  • I have copied the app.config from the generated project and added it to the new class lib. The problem code is:
using (var db = new TestEntitiesDataContext())
{
    var q = from t in db.Tests select t;
}

The compiler is reporting that the "select t" in the above has an issue and underlines "t" and reports: "Cannot convert lambda expression to type 'string' because it is not a delegate type"

The same code works fine when I create the class within the generated project.

App.config

    <connectionStrings>
        <!-- please adjust the connection string embedded in the element below to target the proper catalog / server using the proper user / password combination -->
        <add name="ConnectionString.SQL Server (SqlClient)" connectionString="metadata=res://*/TestEntities.csdl|res://*/TestEntities.ssdl|res://*/TestEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost;initial catalog=Test;integrated security=SSPI;persist security info=False;packet size=4096&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>

Has anyone got any idea as to what I am missing?

Cheers, Marcus

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 21-Jul-2010 14:04:41   

One line....

using System.Linq;

Looks I'm back to "Newbie" status. flushed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 21-Jul-2010 14:31:15   

Marcus wrote:

One line....

using System.Linq;

Looks I'm back to "Newbie" status. flushed

heh simple_smile Yes, those pesky namespaces truly are a problem sometimes when it comes to extension methods: they're not automatically added... simple_smile

Glad it's working now.

Frans Bouma | Lead developer LLBLGen Pro