local variables in EF Linq query
-
I ran into this while trying to use Entity Framework in a WSS application.
var states = context.State.Where(c => c.Country.ID == countryID).ToList();
When binding the resulting query to a dropdownlist you get a Javascript error System.Runtime.CompilerServices.StrongBox`1..ctor(System.__Canon). However, this doesn't get the error
var states = context.State.Where(c => c.Country.ID == 2).ToList();
The work-around for this, as the link below points out, is to use a public variable in a public class rather than a local variable. http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/0dc87db4-c145-456b-a19f-eebc16c09efb/[^]
only two letters away from being an asset
-
I ran into this while trying to use Entity Framework in a WSS application.
var states = context.State.Where(c => c.Country.ID == countryID).ToList();
When binding the resulting query to a dropdownlist you get a Javascript error System.Runtime.CompilerServices.StrongBox`1..ctor(System.__Canon). However, this doesn't get the error
var states = context.State.Where(c => c.Country.ID == 2).ToList();
The work-around for this, as the link below points out, is to use a public variable in a public class rather than a local variable. http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/0dc87db4-c145-456b-a19f-eebc16c09efb/[^]
only two letters away from being an asset
That's one hack of a work around. Yuck.
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango
-
That's one hack of a work around. Yuck.
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango
I was literally just on a call with Microsoft discussing this and so far they have no better solution.
only two letters away from being an asset
-
I was literally just on a call with Microsoft discussing this and so far they have no better solution.
only two letters away from being an asset
Wow. What a shame. Such an ugly hack.
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango
-
I ran into this while trying to use Entity Framework in a WSS application.
var states = context.State.Where(c => c.Country.ID == countryID).ToList();
When binding the resulting query to a dropdownlist you get a Javascript error System.Runtime.CompilerServices.StrongBox`1..ctor(System.__Canon). However, this doesn't get the error
var states = context.State.Where(c => c.Country.ID == 2).ToList();
The work-around for this, as the link below points out, is to use a public variable in a public class rather than a local variable. http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/0dc87db4-c145-456b-a19f-eebc16c09efb/[^]
only two letters away from being an asset
From Microsoft support: This is happening because SharePoint uses its own version of “Medium” trust, which does not enable reflection. The ASP.NET medium trust configuration was changed when Visual Studio 2008 was released to allow reflection in very specific cases. LINQ to SQL and Entity Framework need this permission in order to query in the way that you want. To make this work in your specific scenario, you can add the following in your SharePoint wss_mediumtrust.config file (on my machine it is located in %CommonProgramFiles%\Microsoft Shared\Web Server Extensions\12\config\wss_mediumtrust.config). The only difference is that this will enable code to do reflection to discover non-public members in assemblies that are in the same trust level (i.e. SharePoint Medium trust). (This is a simplification; it’s known as RestrictedMemberAccess, and there is more info here[^].) wss_mediumtrust.config Add the following in the
SecurityClasses
<SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
Then add the following in
PermissionSet
<IPermission class="ReflectionPermission" version="1" Flags="RestrictedMemberAccess"/>
only two letters away from being an asset