Link to home
Start Free TrialLog in
Avatar of universalglove
universalgloveFlag for United States of America

asked on

Implementing an Extension to EntityDataSource in VWD 2010

In Visual Web Developer 2010, I'm trying to implement the extension to EntityDataSource described on this page that enables Insert() to be used as a method:

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/d8a3ecd8-55dd-45ad-8175-d7ce912f46c2/

I get a compile error "CS0246: The type or namespace name 'EntityDataSource' could not be found (are you missing a using directive or an assembly reference?)"

I originally created the class as provided on this page:
http://forums.asp.net/t/1621469.aspx/1

No difference between the 2 (except the 1st link's version actually gets VWD to recognize the EntityDataSourceExtentions class name as something - color codes it in blue-green.)
I should be using .NET 4.0.
Avatar of universalglove
universalglove
Flag of United States of America image

ASKER

These are the contents of the class, saved as EntityDataSourceExtentions.cs in App_Code:

using System.Collections.Specialized;

namespace System.Web.UI.WebControls
{
	public static class EntityDataSourceExtentions
	{
		private static bool DefaultOperationCallback(int affectedRows, Exception ex)
		{
				return false;
		}
		public static void Insert(this EntityDataSource dataSource)
		{
				(dataSource as IDataSource).GetView(string.Empty).Insert(new OrderedDictionary(),DefaultOperationCallback);
		}
	}
}

Open in new window


This is the content of web.config, since that seems to play a role in adding different assemblies to the compile:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="CustomConn" connectionString="Removed=true;" providerName="System.Data.SqlClient" />
    <add name="CustomEntities" connectionString="removed=true;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="TestConn" connectionString="removed=true;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=X1" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=X2" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=X3" />
      </assemblies>
      <buildProviders>
        <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
      </buildProviders>
    </compilation>
    <customErrors mode="Off" />
    <pages>
      <controls>
        <add tagPrefix="custom" tagName="SidebarAds" src="~/_user_controls/SidebarAds.ascx" />
        <add tagPrefix="custom" tagName="ComingSoon" src="~/_user_controls/ComingSoon.ascx" />
        <add tagPrefix="custom" tagName="StateSelect" src="~/_user_controls/StateSelect.ascx" />
      </controls>
    </pages>
  </system.web>
</configuration>

Open in new window


Now that I'm looking at web.config, I noted on a few websites, that there was a difference between "System.Data.Entity" and "System.Web.Entity". Should there be a .Web.Entity assembly added to make this work? Anyone happen to know its tag?
ASKER CERTIFIED SOLUTION
Avatar of universalglove
universalglove
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Found it myself; no time saved.