New Posts New Posts RSS Feed: Joins...
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Forum LockedJoins...

 Post Reply Post Reply
Author
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Topic: Joins...
    Posted: 12-Mar-2010 at 3:21pm
I'm a bit baffled on this one.  I wrote it to simplify it and use NorthwindIB.  Pretend we just didn't have a FK between Orders and OrderDetails.  (I've tried a couple different join methods and all result with the same problem).

If I do the following with Silverlight:

    public MainPage()
    {
      InitializeComponent();

      DomainModelEntityManager mgr = new DomainModelEntityManager();

      int i = 1;
      var q1 = from o in mgr.Orders
               join d in mgr.OrderDetails
                 on new { o.OrderID } equals new { d.OrderID }
               where (d.Quantity > i)
               select o;

      mgr.ExecuteQueryAsync(q1, callback, null);
    }

    public void callback(EntityFetchedEventArgs<Order> args)
    {
      if (args.Error != null)
        MessageBox.Show(args.Error.Message);
      else if (args.Result != null)
        MessageBox.Show(args.Result.ToString());
    }

The args.Error.Message says: "Attempt by method 'System.Linq.Expressions.Expression.CreateLambda(System.Type, System.Linq.Expressions.Expression, System.String, Boolean, System.Collections.ObjectModel.ReadOnlyCollection`1<System.Linq.Expressions.ParameterExpression>)' to access method 'System.Linq.Expressions.Expression`1<System.Func`2<<>f__AnonymousType0`2<DomainModel.Order,DomainModel.OrderDetail>,System.Boolean>>.Create(System.Linq.Expressions.Expression, System.String, Boolean, System.Collections.ObjectModel.ReadOnlyCollection`1<System.Linq.Expressions.ParameterExpression>)' failed."

However, the same code in a console app runs just fine.  The only difference is the WCF and of course the actual library code.  Any idea where the problem is?

Also... If I don't use a variable, it runs fine:  d.Quantity > 1

Thanks.

Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 16-Mar-2010 at 5:45pm
Hi Mike,
 
Thanks for mocking up a simple example that runs against NorthwindIB!  We will run some tests on it over here.
 
In the meantine, have you tried the join syntax without using 'new'?  I think it can be written as:
join d in mgr.OrderDetails on o.OrderID equals d.OrderID ...
 
Back to Top
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Posted: 18-Mar-2010 at 9:36am
Yes, I tried quite a few join methods.  Anything with a variable fails in Silverlight but works fine in the .net library

      var q1 = from o in mgr.Orders
               join d in mgr.OrderDetails
                 on  o.OrderID equals d.OrderID
               where (d.Quantity > i)
               select o;

      var q1 = mgr.Orders
                  .Join(mgr.OrderDetails,
                        o => o.OrderID,
                        d => d.OrderID,
                        (o, d) => new { o = o, d = d })
                  .Where(r => r.d.Quantity > i)
                  .Select(r => r.o);

Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 18-Mar-2010 at 3:10pm
Yes, we confirmed this issue as well.  There is a problem with the closure in Silverlight (as you noted, it works when you use a constant instead of i).
 
We've added this to the bug base and will get it fixed.  Thanks for pointing this out!
 
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 06-Apr-2010 at 3:55pm
In order to get this to work, the assembly containing this code must be grant trust to System.Core.  We've modified the templates for DevForce 2010 to do this automatically.
 
For DevForce 2009 and for any new client assemblies you may create (in either product), you will need to add the following assembly level attribute (to AssemblyInfo.cs):
 
[assembly: InternalsVisibleTo("System.Core, PublicKey=00240000048000009400000006020000002400005253413100040000010001008d56c76f9e8649383049f383c44be0ec204181822a6c31cf5eb7ef486944d032188ea1d3920763712ccb12d75fb77e9811149e6148e5d32fbaab37611c1878ddc19e20ef135d0cb2cff2bfec3d115810c3d9069638fe4be215dbf795861920e5ab6f7db2e2ceef136ac23d5dd2bf031700aec232f6c6b1c785b4305c123b37ab")]
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down