.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

EntitySet does not contain a public definition for GetEnumerator

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net

I've been having this problem since switching to MVC2. This isn't a new project, so not the usual wrong version type in the web.config file. Anyways, here is the scenario:

Two Tables:

Projects { 
   public int id { get; set; }
   public string name { get; set; }

Tasks { 
   public int id { get; set; }
   public string name { get; set; }
   public int fk_project_id { get; set; }

I've created these two tables in a linq-2-sql class and I have a strongly typed view of projects. I can loop through the projects just fine, but I get an error when I try to loop through the tasks associated with the projects.

"foreach statement cannot operate on variables of type 'System.Data.Linq.EntitySet<Program.Models.Task>' because 'System.Data.Linq.EntitySet<Program.Models.Task>' does not contain a public definition for 'GetEnumerator'"

<% foreach (var item in Model) { %>
  <% foreach (var task in item.Tasks) { %>
  <% } %>
<% } %>

View Complete Post

More Related Resource Links

Public Shared function doubt????

I am using VB.net/ASP.NET and SQL Server 2000 for a web application.

For populating the dropdowns, I wrote a Public Shared function LoadDDL(), in which I pass the dataset and dropdown name to set.

I have my doubts that this function will produce unexpected results for concurrent users. And will mix the results among sessions because it is a Shared function.

I am confused here. Is it the right way to go?

Please advice. Thanks in advance.


NUnit and public static readonly


I have an app that I am testing with NUNit.  The project im testing has several helper classes that are created as public static readonly.  When I run the NUnit tests, they all fail with the same error

SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.
  ----> System.NullReferenceException : Object reference not set to an instance of an object.
SetUp : System.TypeInitializationException : The type initializer for 'Systems.Utils.ConstantHelpers' threw an exception.
  ----> System.NullReferenceException : Object reference not set to an instance of an object.

I kept getting this error despite stripping out all

SOAP Toolkit 2.0: New Definition Languages Expose Your COM Objects to SOAP Clients


In SOAP Toolkit 2.0, the Services Description Language (SDL) has been replaced with the Web Services Description Language (WSDL) and the Web Services Meta Language (WSML). WSDL and WSML files describe the interfaces to a service and expose COM objects to SOAP clients. This article describes a custom tool, IDL2SDL, which takes an IDL file and produces WSDL and WSML files without waiting for a DLL or TLB file to be generated. Also shown is a customized development environment in which WSDL and WSML files automatically reflect the changes to IDL files.

Carlos C. Tapang

MSDN Magazine April 2001

report definition is not valid



I recently upgraded to VS 2010.  One on of my reports I am getting the following error.  Can someone help?

The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded.

Thank you.

Issue with List Definition of same base content type and deployed via same feature


I am trying to deploy two custom list definitions using only one single feature.  Below are the details of my issue.

  • Two custom list definitions
  • Each custom list definition has its own custom content type
  • Each custom content type inherits from the base content type Picture (Type = 109)
  • The custom list definitions are grouped together under one single feature
  • The custom content types are grouped together under a seperate single feature

When I deploy my solution in this configuration, the second list definition gets the first custom content type applied to it and the list schema from the first list definition is also applied to the second list definition.

What makes this more interesting, when I seperate both of the list definitions under two seperate features it all works fine.  Custom content types and list schemas get applied correctly.

Can anyone tell me why I can not deploy both list definitions under one single feature?

If you need me to post any of the origional code or XML to this post please let me know.



Trouble with Font Definition in Accordion Control


 VWD 2008 Express.

I have a page on which I have an accordion control.  The accordion control seems to be overriding the font definition I have for the page body in my CSS stylesheet.  Here is what is happening.  Can anyone help?  Thanks.

1.  When I open the page and the top panel opens, it displays with the correct font family, size, etc.

2.  If I close and reopen the top panel, it displays with another font family and looks bad.

3.  All subsequent panels, when opened, display the font in a different family than specified in my CSS stylesheet.

This is what I have in the stylesheet both for the body and for the .accordioncontent:

    background-color: #E4E1C2;
    background: url(../images/background.jpg) repeat left top;
    font-family: Georgia, "Times New Roman" , Times, serif;
    color: #666666;
    font-size: 12pt;
    border-top: none;
    padding-top: 10px;
    font-family: Georgia, "Times New Roman" , Times, serif;
    color: #666666;
    font-size: 12pt;


public object on asp,net page


in asp.net can i make public objects on my page, for example

public Customer cust1 = new customer();

and use this object on my entire code???

what are the drawbacks of creating public objects??

a single object will be created for all users??? or each user will have a different object????

What pattern do I use to capture an entire C# method definition with all modifiers, method name and

Hello all,Given a C# method named MyMethod, what pattern do I use to capture the entire definition, including modifiers, method name and opening and closing braces, irrespective of bracket styles, given that the method will probably contain 1-n other pairs of braces, embedded or not, etc? In this case, I don't care about the actual method definition, I just need to capture it all in one chunk.    a. public int MyMethod(int parm){            if (...) {            }       }    b. public int MyMethod(int parm)       {            if (...) {            }       }Thanks in advance for any ideas and/or suggestions!

mail definition????

I have my code....but it is sending the actual html in the mail.....not the html page.Imports System.Net.MailImports System.ReflectionImports System.Collections.SpecializedPartial Class Admin    Inherits System.Web.UI.Page    Function ShowMessage(ByVal msg As System.Net.Mail.MailMessage) As HtmlTable        Dim table As HtmlTable = New HtmlTable        Dim topRow As HtmlTableRow = New HtmlTableRow        Dim fieldHeaderCell As HtmlTableCell = New HtmlTableCell        Dim valueHeaderCell As HtmlTableCell = New HtmlTableCell        fieldHeaderCell.InnerText = "Field"        topRow.Cells.Add(fieldHeaderCell)        valueHeaderCell.InnerText = "Value"        topRow.Cells.Add(valueHeaderCell)        table.Rows.Add(topRow)        Dim p As PropertyInfo        For Each p In msg.GetType().GetProperties()            Dim row As HtmlTableRow = New HtmlTableRow        &n

Set Site Icon in Site Definition

Hi,I am trying to set the default Site Icon in my custom site definition.I have changed the titlegraphic.gif in my master page to a new name but that didn't work.In the site definition I have also set the SiteLogoUrl to an image, but that didn't work either.Some people suggest that you should replace the default titlegraphic.gif file with your own image and give it the same name, but I don't see how this could be any good since an update to the sharepoint installation might just overwrite the image again with the default one.Any help would be appreciated!Thanks

Required attribute with resource definition uses wrong language

Hi all,I'm having a problem with a multilanguage application in MVC. On my model I'm using the following:[Required(ErrorMessageResourceType = typeof(VlanResources.Errors), ErrorMessageResourceName = "Common_NameRequired")] This takes care of validation... However the messages are always in the default language. Meaning that the setting of the culture of my thread is occuring too late (I'm currently setting it in my base controller 'OnActionExecuting'). Where could I patch in to change the culture accordingly before validation takes place?Thank you for your assistance,Ivan

Creating a new root Site Collection using a custom site definition file (ONET.XML)

Using Powershell, I am trying to deploy the our custom solution to SP 2010.  The script is doing the following: Deleting the web application using Remove-SPWebApplication Creating a new web application using New-SPWebApplication Adding and deploying a series of WSP files (one of which has the site definition file in it) using Add-SPSolution and Install-SPSolution Create a root site collection based on the site definition file provided in the WSPs using New-SPSite I get the error "WARNING: Template is not found and is not applied." When I run Get-SPWebTemplate, my site definition does not show up. I saw this: http://social.msdn.microsoft.com/Forums/en/sharepoint2010general/thread/5ea46e07-a4b0-4bab-b698-9b6eeb695607 but I want a solution that does not involve me reloading a DLL, as, I feel there is something else I am forgetting. I have also tried: IISReset Resetting the timer service Cleaning the Cache (as described here: http://support.microsoft.com/kb/939308) Nothing seems to work.  Does anyone have any ideas?

BDC to BCS Application Definition Upgrade

I'm trying to perform an upgrade of a SharePoint 2007 environment to 2010. Our plan is to move to entirely new hardware and do a content database migration. In such a scenario, it seems that BDC application definitions are not upgraded as part of the process. Also, it seems that the 2007 app definition file format is not compatible with BCS. In an in-place upgrade I understand that these settings get migrated as part of the upgrade process. Is there any way to access the upgrade facility, either through a utility or even via the API to perform the conversion?   Thanks, DanDaniel Segan

Custom Alert Filter Definition

I was trying to create custom filter definition. Requirement : Send alert when the body of discussion contains certain words. These words are to be configurable. I just followed the steps in this blog. http://blogs.msdn.com/b/sharepointdeveloperdocs/archive/2007/12/07/customizing-alert-notifications-and-alert-templates-in-windows-sharepoint-services-3-0.aspx Created seperate template xml and added the definition like below <Filters> <FilterDefinition> <FriendlyName>Post contains </FriendlyName> <ShortName>words or phrase </ShortName> <Query> <Where> <Contains> <FieldRef Name="Body" /> <Value Type="Note">hi</Value> </Contains> </Where> </Query> </FilterDefinition> </Filters> I'm getting some blank radio buttons in the alert configure page, not sure whether to add the custom entries to resource file, where to make changes in core resource file? The value I'm trying to search is hardcoded now in the CAML, I want some text box for entering the value. Please advise.

Invalid data has been used to update the list Item.(List definition)

<nativehr>0x80070057</nativehr><nativestack></nativestack>Invalid data has been used to update the list item. The field you are trying to update may be read only. I have created a list definition and into that i have created lookup column when i am trying to add any item into the list then it gives me an error as above. Can anyone help me.? I made the readonly attributes to false for lookup columns.  

Bug: Specifying values in the definition of an enum in Web Parts in subsites

Pardon the cumbersome title, but I wanted to make it as descriptive as possible! Anyway, I stumbled upon this bug and spent a good while trying to figure out what was wrong. I'm developing a WebPart for use in MOSS 2007. The WebPart in question is mostly unremarkable, but I was getting the following error when editing the WebPart properties: "Some of the properties for this Web Part cannot be displayed properly. For more information, see your site administrator." I've searched Google, Bing and Yahoo for this error and have found nothing, so hopefully this post will be of use to anyone else who searches for it. Turns out the problem was in the enumerator definition. It looked like this:   public enum KPIPalette { Grey = 1, Green, Blue, Orange }   The colour palettes of the components we're using started at 1, so I set the enumerator to do that also. SharePoint, however, had other ideas. The solution is to leave enumerator definitions out. When the number was required later in code, a 1 was added. Error begone, problem solved!

How do I publish public facing SharePoint site(on internet)?

I developed public facing SharePoint 2010 portal publishing website using Window Server 2008 R2 and SharePoint 2010 Server and SPD 2010 on my computer. I have custom master page, page layout, css…. I want to publish it(on the internet).  I want to know cheap host and domain name service provider Company and steps to do it. I’ appreciate any advice in advance.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend