This website is intended as archive for old content and forums.
Please visit http://opf3.codeplex.com for the project's new website.

Wishlist

FORUM TOPIC

Do you have a great idea about Opf3? Let us know and maybe your features will be in the next release!

RSS
Nick Dinges
Posted on the 09/06/07 10:24 AM
LINQ
Reply Quote
 any planings to implement LINQ in OPF3 ?

Christian Liensberger [Moderator]
Posted on the 09/06/07 10:31 AM
RE: LINQ
Reply Quote
 I have a working prototype here Happy Just need to find somebody to test it out. Anybody willing?

Alfred Ortega
Posted on the 09/07/07 5:18 PM
RE: LINQ
Reply Quote
 I'm willing! I've been playing with it more and more over the last month or so and it rocks.

Al

Christian Liensberger [Moderator]
Posted on the 09/07/07 5:56 PM
RE: LINQ
Reply Quote
 OK! I'll send you an e-mail Ninja

Christian

Onorio Ribolzi
Posted on the 10/03/07 6:20 PM
RE: LINQ
Reply Quote
 Any news about Linq ?

Alfred Ortega
Posted on the 10/03/07 7:33 PM
RE: LINQ
Reply Quote
 From playing with the test build here is some sample syntax. The best part (for me) is that this was tested against an Oracle DB and Access and still worked.

simple LINQ syntax:

var query = from c in context.GetPersistents<Contact>()
                  orderby c.ContactID
                  select c;    



LINQ Against an existing Objectset

ObjectSet<Contact> contacts = query.GetObjectSet();
//noticed how the where clause is based on a based on a related object - so cool! :=D
var newquery = from c in contacts
               where c.ContactType.Type.ToUpper() == "BUYER"
               orderby c.LastName
               select c;      



Get an Anonymous type against an existing ObjectSet

var anonquery = from c in contacts
                where c.ContactType.Type.ToUpper() == "BUYER"
                orderby c.LastName
                select new { ContactID = c.ContactID
                                 , LastName = c.LastName
                                 , Firstname = c.FirstName };



joins

var query = from c in context.GetPersistents()              
            join u in context.GetPersistents() on c.ID equals u.ID
            select u;    



To Setup Your context only requires adding a line of code:

ObjectContext context = new ObjectContext(new MsSqlStorage("sa", "password", "localhost\\sqlexpress", "Test"));  
Specify the command builder to have LinqQueries translated into SQL.  
context.Storage.StorageCommandBuilders.Add(new LinqQueryCommandBuilder());


There are still some bugs to work out but overall it works great. The ability to execute LINQ against any DB (supported by Opf3 of course) and not just MsSql is huge. Additionally LINQ allows running queries against in memory ObjectSets provides all kinds of ways to enhance local caching for clients.

hth
Al


Christian Liensberger [Moderator]
Posted on the 10/04/07 8:04 AM
RE: LINQ
Reply Quote
 

Onorio Ribolzi wrote:
Any news about Linq ?


I'm working on it right now. If you want to test it out, please an e-mail to support :) The e-mail addresses are found here: http://www.opf3.com/Opf3/About/Contact.aspx

Alfred Ortega
Posted on the 12/05/07 10:21 PM
RE: LINQ
Reply Quote
 Any updates or testing that you still need help with?

-Al

Christian Liensberger [Moderator]
Posted on the 12/08/07 11:42 AM
RE: LINQ
Reply Quote
 Hi!

there are no updates so far... I'm still working on it :)

Christian

Alfred Ortega
Posted on the 12/09/07 12:46 AM
RE: LINQ
Reply Quote
 Cool, thanks for the update. Here's a bug for you in case you didn't already have it

string LastNameSearchString = "Smith";
var analystlist = from analysts in context.GetPersistents<Analyst>()
                         where analysts.LastName == LastNameSearchString
                          select analysts;


The exception I get is an "System.ArgumentOutOfRangeException: Length cannot be less than zero". I can send the full details if you want although I'm sure it' easy to reproduce Big Grin!

I also tried using contains and startswith:

var analystlist = from analysts in context.GetPersistents<OSI.Analyst>()
                        where analysts.LastName.Contains(LastNameSearchString)
                        select analysts;


They don't throw an exception but they generate the following SQL

Select * from Analyst where LastName =


and all records are returned!

Al

Alfred Ortega
Posted on the 01/12/08 12:22 AM
RE: LINQ
Reply Quote
 Hey just out of curiosity is the new version going to be based on Linq To Entities?

-Al

Christian Liensberger [Moderator]
Posted on the 01/12/08 10:27 AM
RE: LINQ
Reply Quote
 Hi!

LINQ to entities is a new framework. Opf3 is not going to be based on it because that would really mean a complete rewrite of the framework.

Christian

Christian Liensberger [Moderator]
Posted on the 02/18/08 2:27 PM
RE: LINQ
Reply Quote
 I have created a short blog post to show how to set LINQ to Opf3 up: http://www.liensberger.it/web/blog/?p=235

Michel Taal
Posted on the 04/23/08 10:30 AM
RE: LINQ
Reply Quote
 I also have this problem in the 3.0.14.1043 version. If i use a variable in the where clause it doesnt work. Has this already been fixed?

Alfred Ortega wrote:
Cool, thanks for the update. Here's a bug for you in case you didn't already have it

string LastNameSearchString = "Smith";
var analystlist = from analysts in context.GetPersistents<Analyst>()
                         where analysts.LastName == LastNameSearchString
                          select analysts;


The exception I get is an "System.ArgumentOutOfRangeException: Length cannot be less than zero". I can send the full details if you want although I'm sure it' easy to reproduce Big Grin!

I also tried using contains and startswith:

var analystlist = from analysts in context.GetPersistents<OSI.Analyst>()
                        where analysts.LastName.Contains(LastNameSearchString)
                        select analysts;


They don't throw an exception but they generate the following SQL

Select * from Analyst where LastName =


and all records are returned!

Al



Christian Liensberger [Moderator]
Posted on the 04/23/08 2:47 PM
RE: LINQ
Reply Quote
 Send me an e-mail over and I will send you an updated version. I'm working on Opf3 right now and I'm going to release the changes in the near future!

Joel Meikle
Posted on the 01/20/09 9:02 AM
RE: LINQ
Reply Quote
 Hi, I'm also getting a linq exception but its slightly different to the c# errors.

'VB.NET
Dim users = From u In context.GetPersistents(Of DAL.ApplicationUser)() Where u.LogonName = "admin" Select u


the error is a sql error "invalid syntax near ="

the generated sql (from users.ToString) is
"select [ApplicationUsers].* from [ApplicationUsers] where (( = @p0))"

its like its not picking up the field name in the where clause.

Here is the property from the ApplicationUser class

    <Field(FieldName:="LogonName", AllowDBNull:=False)> _
    Public Property LogonName() As String
      Get
        Return _LogonName
      End Get
      Set(ByVal Value As String)
        _LogonName = Value
      End Set
    End Property


Cheers,
Joel

Christian Liensberger [Moderator]
Posted on the 01/20/09 11:38 AM
RE: LINQ
Reply Quote
 Could you send me a mail. I have a newer version of the LINQ provider available and could send you that one.

Alfred Ortega
Posted on the 01/20/09 5:44 PM
RE: LINQ
Reply Quote
 So is there a new version coming out then?

Christian Liensberger [Moderator]
Posted on the 01/20/09 5:47 PM
RE: LINQ
Reply Quote
 Sure Al. But you have already that "new" version ;) The joins are still missing.

Alfred Ortega
Posted on the 01/20/09 6:10 PM
RE: LINQ
Reply Quote
 Yes the Joins would be great to have. Any time frame on when it may be coming?

All times are in GMT.