none
Entity Data Model 'xxx' does not contain a definition for 'xx' and no extension method 'xx' accepting a first argument of type 'xxx could be found (are you missing a using directive or an assembly reference?) RRS feed

  • Question

  • i get en error on my web site project login page and gallery page

    here is the error

     'Yoneticiler' does not contain a definition for 'Yetki' and no extension method 'Yetki' accepting a first argument of type 'Yoneticiler' could be found (are you missing a using directive or an assembly reference?)

    when i first time run the project there are no errors, i did not change anything but now i get errors

    My login page codes

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using SaliniCollectionModel;
    
    public partial class Giris : System.Web.UI.Page
    {
             public List<Yoneticiler> yoneticim()
        {
            SaliniCollectionEntities model = new SaliniCollectionEntities();
            List<Yoneticiler> liste = new List<Yoneticiler>();
            var sorgu = from y in model.Yoneticiler where y.KullaniciAdi == txtKadi.Text.Trim() && y.Sifre == txtSifre.Text.Trim() select new { y };
    
            foreach (var item in sorgu)
            {
                liste.Add(item.y);
              
            }
    
            return liste;
        
        }
    
      
    
        bool giris(string kadi, string sifre)
        {
            bool sonuc = false;
            SaliniCollectionEntities model = new SaliniCollectionEntities();
            List<yoneticiGetir> admin = (from ad in model.yoneticiGetir where ad.KullaniciAdi == kadi && ad.Sifre == ad.Sifre select ad).ToList();
    
            if (admin.Count > 0)
            {
                sonuc = true;
            }
    
            List<Yoneticiler> liste = new List<Yoneticiler>();
    
            foreach (yoneticiGetir item in admin)
            {
    
            }
    
            return sonuc;
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["Kullanici"] = null;
    
            }
    
    
        }
        protected void btnGiris_Click(object sender, EventArgs e)
        {
            string kadi = txtKadi.Text.Trim();
            string sifre = txtSifre.Text.Trim();
            //if (gir().Count>0)
            //{
            //    Response.Redirect("~/AdminGaleri.aspx");
            //}
            if (giris(kadi, sifre) == true)
            {
    
                Session["Kullanici"] = yoneticim();
                Response.Redirect("~/AdminGaleri.aspx");
            }
    
          
    
        }
    }

    My Gallery page codes

        private bool isAdmin { get; set; }
        private bool isManager { get; set; }
    
      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<Yoneticiler> yonetici = null;
               
                if (Session["Kullanici"]==null)
                {
                    Response.Redirect("~/Giris.aspx");
                   
                }
                    else
             	{
                    yonetici =(List<Yoneticiler>) Session["Kullanici"];
                    if (yonetici[0] != null && yonetici[0].Yetki == 1)
                    {
                        isAdmin = true;
    
                    }
    
                    else if (yonetici[0] != null && yonetici[0].Yetki == 0)
                   {
                    isManager = true;
                    lnkEkle.Visible = false;
                    lnkSil.Visible = false;
                    lnkGuncelle.Visible = false;
                   }             
        	}
    
                
                try
                {
                    getir();
                }   
                catch (Exception)
                {
                    
                   
                }
               
            }
        }

    • Moved by Lisa Zhu Tuesday, April 16, 2013 12:54 PM EF related
    Monday, April 15, 2013 10:28 PM

Answers

  • On 4/16/2013 7:50 AM, CanEmre wrote:

       thanks for your help.  i try to make an admin panel. on my  login page i try to select Yoneticiler (admin) and send it to gallery page with session then on gallery page i check admins role with YETKİ.

        i checked the links but i did not understand clearly how can i do this.

    You can't make "Y" "new" in the Linq query. "Y" is an object that already exist in the query and defined.
     You defined "Y" when you did... from Y in db.Table... So how can you be making a "new" "Y" at the other end of the Linq statement when it already exist? You can't do it.

    You have to Select "Y" at the end of the statement  only -- no Select New "Y"
     You can make a new object from "Y" and use Y's properties to shape/project a new "object" with all of Y's properties or part of Y's properties.
     I suggest that you look-up Linq projection  and using Anonymous Types in a new Linq shape/projection query.
     You can also do a Select y.name, y.address and those are the only properties that are going to be in the result objects of the Linq query from "Y".

    You can do all the properties of "Y" or just Select Y.

    <http://www.codeproject.com/Articles/93645/LINQ-to-Entities-Projection>
     <copied>

    Anonymous Type Projection
      Collapse | Copy Code
    var query = from emps in context.Employees select new { emps.Age };
    var query = from emps in context.Employees select new { NewAge = emps.Age };

    Both queries above will perform the proper projection, similar to the T-SQL queries. The first will return a list of Ints under the column “Age” and the second “NewAge”. The Select new syntax is how Linq to Entities handles projecting data into an anonymous type.

    <end>
     <http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b>
     Lots of examples on how to use Linq.
     <http://www.linqpad.net/>

    Tuesday, April 16, 2013 12:38 PM

All replies

  • On 4/15/2013 6:28 PM, CanEmre wrote:

      var sorgu = from y in model.Yoneticiler where y.KullaniciAdi == txtKadi.Text.Trim() && y.Sifre == txtSifre.Text.Trim() select new { y };

    What is  a select new {y}? What's "new" about "y"? You have given no new projection properties in the Linq query using anonymous type,  if that was your intent.

    Either it's just.........

    select y;

    or

    Select new { Help = y.Help,  Me = y.Me};

    <http://www.developerfusion.com/article/7556/new-c-30-language-features/4/>

    <http://msdn.microsoft.com/en-us/library/bb738447.aspx>
     I could be wrong, but the your statement above seems kind of strange.

    Monday, April 15, 2013 11:18 PM
  •   thanks for your help.  i try to make an admin panel. on my  login page i try to select Yoneticiler (admin) and send it to gallery page with session then on gallery page i check admins role with YETKİ. 

       i checked the links but i did not understand clearly how can i do this.

    Tuesday, April 16, 2013 11:50 AM
  • On 4/16/2013 7:50 AM, CanEmre wrote:

       thanks for your help.  i try to make an admin panel. on my  login page i try to select Yoneticiler (admin) and send it to gallery page with session then on gallery page i check admins role with YETKİ.

        i checked the links but i did not understand clearly how can i do this.

    You can't make "Y" "new" in the Linq query. "Y" is an object that already exist in the query and defined.
     You defined "Y" when you did... from Y in db.Table... So how can you be making a "new" "Y" at the other end of the Linq statement when it already exist? You can't do it.

    You have to Select "Y" at the end of the statement  only -- no Select New "Y"
     You can make a new object from "Y" and use Y's properties to shape/project a new "object" with all of Y's properties or part of Y's properties.
     I suggest that you look-up Linq projection  and using Anonymous Types in a new Linq shape/projection query.
     You can also do a Select y.name, y.address and those are the only properties that are going to be in the result objects of the Linq query from "Y".

    You can do all the properties of "Y" or just Select Y.

    <http://www.codeproject.com/Articles/93645/LINQ-to-Entities-Projection>
     <copied>

    Anonymous Type Projection
      Collapse | Copy Code
    var query = from emps in context.Employees select new { emps.Age };
    var query = from emps in context.Employees select new { NewAge = emps.Age };

    Both queries above will perform the proper projection, similar to the T-SQL queries. The first will return a list of Ints under the column “Age” and the second “NewAge”. The Select new syntax is how Linq to Entities handles projecting data into an anonymous type.

    <end>
     <http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b>
     Lots of examples on how to use Linq.
     <http://www.linqpad.net/>

    Tuesday, April 16, 2013 12:38 PM
  • Hi CanEmre,

    Welcome to the MSDN Forum.

    From your description, I ‘d like to move this post to  the most related forum.There are more  experts in this aspect, so you will get  better support and  may have more luck getting answers.

    Thanks for your understanding.

    Regards,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    • Edited by Lisa Zhu Tuesday, April 16, 2013 12:53 PM
    Tuesday, April 16, 2013 12:49 PM