Identifier is not a parameter or variable

Thread is closed for posting
2 posts, 0 answers
  1. Alex Serg
    Alex Serg avatar
    2 posts
    Member since:
    Mar 2005

    Posted 16 Apr 2014 Link to this post

    I've downloaded and use Telerik Data Access Q1 2014 SP1 (2014.1.403.2). I have the model based on the Database First pattern. Database has the "Operation" table. In my project I've generated model from Database. Thats works fine! But I need to add custom property into one of the entities, like this:

    public partial class Operation {
       private string statusText = "Active";
       public string StatusText
          get { return this.statusText; }
    This property does not need to exist into database table - it's defined and used only in .Net.
    The Exception: "Identifier 'StatusText' is not a parameter or variable or field of 'Operations.DAL.Operation'. If 'StatusText' is a property please add the FieldAlias or Storage attribute to it or declare it as a field's alia"  occurs when I try to run following code:
    var result = _context.GetAll<Operation>().Where(x => x.StatusText == "Active").ToList();

    I tried to add Storage and FieldAlias attribute as well, but exception still occurs.

    Can I have an extened property in partial class without having to exist it in the database table?

  2. Boris Georgiev
    Boris Georgiev avatar
    190 posts

    Posted 18 Apr 2014 Link to this post

    Hi Alex,

    The code which you are trying to run:
    _context.GetAll<Operation>().Where(x => x.StatusText == "Active").ToList();
    will be executed on two passes:

    GetAll<Operation>().Where(x => x.StatusText == "Active")
    which is of IQueryable type and will create an SQL statement and will be executed on the server. So the statement will compare the column mapped to StatusText property to the value "Active". But in your case this column is not existing in the database and the idea of the property is to be used only in .NET and in memory operation.
    2) The second pass will be to cast the returned IQueryable object to IList object in memory.

    No matter what attributes you add to the property, when you try to insert it in the sql statement which will be executed on the server, the OpenAccessContext will thrown this exception.

    I hope that helps.

    Boris Georgiev
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Back to Top