?
Solved

Implementing an Extension to EntityDataSource in VWD 2010

Posted on 2013-05-14
3
Medium Priority
?
311 Views
Last Modified: 2013-05-15
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.
0
Comment
Question by:universalglove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 

Author Comment

by:universalglove
ID: 39168897
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?
0
 

Accepted Solution

by:
universalglove earned 0 total points
ID: 39169062
Apparently the verbiage I needed to know is "reference".
And the menu to deal with this in VWD is Website > Add Reference... followed by the .NET tab.

Gives me:
        <add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

Open in new window


(And just to know, apparently the PublicKeyToken is not any sort of sensitive data.
Helpful info:
http://stackoverflow.com/questions/4807420/adding-assembly-reference-within-web-config
http://en.wikipedia.org/wiki/.NET_assembly
)

And, finally, I added the EntityDataSourceExtentions.cs file back into the App_Code folder, and rebuilt the site, and I don't get the compile error anymore.
(Funny that I should have to add in a reference to that assembly when I'm already using the datasource in the page successfully. Be blessed if I knew how it was all working.)
So while I still don't know if EntityDataSource.Insert() will solve my design problem, I at least got past the initial, obnoxious compile error.
0
 

Author Closing Comment

by:universalglove
ID: 39169065
Found it myself; no time saved.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question