[Mono-list] Should LINQ work in Mono 2.0.1?

Adam Tauno Williams awilliam at whitemice.org
Wed Dec 10 22:03:03 EST 2008

On Wed, 2008-12-10 at 21:34 -0500, Chris Howie wrote:
> On Wed, Dec 10, 2008 at 9:29 PM, Adam Tauno Williams
> <awilliam at whitemice.org> wrote:
> > I've got a simple LINQ example in Monodevelop (openSUSE,
> > mono-core-2.0.1) and it fails to build with:
> > Type=Error, Priority=Normal, Description=An implementation of `Cast'
> > query expression pattern could not be found. Are you missing
> > `System.Linq' using directive or `System.Core.dll' assembly
> > reference?(CS1935)
> > The project references System.Core, and System.Data.Linq,  I have a
> > System.Data.Linq and a System.Xml.Linq, but no System.Linq.
> Just add "using System.Linq;" to the top of your source file.  This
> namespace is part of the System.Core assembly.

Sweet!  It even works on with a Db4o database in client/server mode.

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using Db4objects.Db4o;
using Db4objects.Db4o.Linq;

namespace DB4oCS.Test
  class MainClass
    public static void Main(string[] args)
      IObjectSet        results;
      Server s = new Server();
      IObjectContainer client = s.Client;
      client.Store(new Car(1, "red"));
      client.Store(new Car(2, "yellow"));
      client.Store(new Car(3, "yellow"));
      client.Store(new Car(4, "blue"));
      client.Store(new Car(5, "red"));
      client.Store(new Car(6, "white"));
      IEnumerable<Car> cars = from Car c in client
                          where c.Color.Equals("yellow") && c.Id > 2
                          select c;
      foreach(Car c in cars) Console.WriteLine(c.Id);

More information about the Mono-list mailing list