Linq to Entities

Last post 07-06-2009 9:08 AM by jivandf. 6 replies.

Sort Posts:

  • Linq to Entities

    06-29-2009, 11:46 AM

    Can anyone help me or give me an example I can use to manage this.


    I have created a project and added the datasource and created the ado.net entities.

    The edmx file was successfully made and my namespace is eImageModel but when I create a new class file and do using eImageModel I get


    Error    1    The type or namespace name 'eImageModel' could not be found (are you missing a using directive or an assembly reference?)  


    Why is this happing am I missing something?


    I have been following this website:

    http://naspinski.net/post/Getting-started-with-Linq-To-Entities.aspx


    Thanks for any help.

  • Re: Linq to Entities

    06-30-2009, 2:28 AM
    • Member
      204 point Member
    • sethi.bhushan
    • Member since 11-13-2007, 10:09 AM
    • India
    • Posts 51

    Hi

    Open your edmx.designer.cs file and check namespace written on that. That'll be different than edmx file name.

    Use that namespace that will work.


    MARK THIS AS ANSWER IF IT HELPS YOU

  • Re: Linq to Entities

    06-30-2009, 2:42 AM
    • Star
      12,441 point Star
    • malcolms
    • Member since 06-12-2008, 12:38 AM
    • Melbourne, Australia
    • Posts 2,044

    You may need to full qualify your namespace.  So your namespace could be eImageModel, but qualify that by the project name.  So if your application is MyWebApp use MyWebApp.eImageModel.

    Sincerely,
    Malcolm Sheridan

    Microsoft Certified Solution Developer
    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as
    Answer" if a marked post does not actually answer your question.
  • Re: Linq to Entities

    06-30-2009, 4:22 AM

    Thanks for the replys.


    I am pretty sure I am using the namespace of the entity.


    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="eImageModel", Name="Files")]


    I would imagine eImageModel is the name space?


    Even trying the two following namespace using I can't get thi working.


    using eImage.eImageModel; or

    using eImageModel;


    Forgot to mention that I have the following using controls, am I missing one?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.Objects;
    using eImageModel; <- Failling for some reason


    Also I am working with .net 3.5 if that makes any difference?

  • Re: Linq to Entities

    06-30-2009, 5:09 AM
    Answer
    • Member
      204 point Member
    • sethi.bhushan
    • Member since 11-13-2007, 10:09 AM
    • India
    • Posts 51

    No This is not the namespace that you are using.

    Namespace should be just be below these global declarations

    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="eImageModel", Name="Files")]

    Namespace name should be below this and above your partial class .

    If it no there do like this 


    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="eImageModel", Name="Files")]

    /****New Added line **/

    namespace YourNameSpace   //it should use in Using cluase on pages.

    {

    /********/

    public partial class YourDataContextName : global::System.Data.Objects.ObjectContext

    {....}


    /****closing braces of namespace added **/

     }

    /********/


  • Re: Linq to Entities

    06-30-2009, 8:48 AM
    Answer
    • Star
      12,441 point Star
    • malcolms
    • Member since 06-12-2008, 12:38 AM
    • Melbourne, Australia
    • Posts 2,044

    If you're still having issues you can use the built-in resolve namespace feature inside of studio.  Type the name of your class, make sure you have the case correct, right click on the typed class name abd in the dialog box you should see a Resolved option.  See the screen shot below:



    Sincerely,
    Malcolm Sheridan

    Microsoft Certified Solution Developer
    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as
    Answer" if a marked post does not actually answer your question.
  • Re: Linq to Entities

    07-06-2009, 9:08 AM
    Answer
    • Member
      14 point Member
    • jivandf
    • Member since 12-28-2007, 8:27 AM
    • Brasil
    • Posts 16

     

    I think if you created a web project your edmx has a namespace like

    namespace App_Code {
      partcial Class eImageModel
      {
      }
    }
    Instead of using using in your new class, try to inform the same namespace

    I believe that if your classes are within the same namespace you will have no more problem.
    Programmer Web C# .NET
    Email: ivan@idevweb.com.br
    Portfolio: http://www.idevweb.com.br
    Mobile: +55(61) 8406-9719
    Phone: +55(61) 3395-3383

    "God loved the world so that gave his only Son so that whoever believeth in him should not perish but have eternal life." (John 3:16)
Page 1 of 1 (7 items)