Linq where clause not working in Open access

5 posts, 0 answers
  1. Lafama
    Lafama avatar
    12 posts
    Member since:
    Oct 2009

    Posted 31 May 2010 Link to this post

    hi, i have the following basic select statement
    var result = from temp in scope.Extent<x>()
                             where temp.ID == 1
                             select temp;
                foreach (x xTemp in result.ToList())
                {
                    Console.WriteLine("::::"+xTem.Name+"::"+xTemp.ID);
                }
    but i get the following error
    .System.InvalidOperationException : An exception occured during the execution of '
    Extent<x>.Where(temp => (temp.ID = 1))'. See InnerException for more details.

    ----> Telerik.OpenAccess.OpenAccessException : Identifier 'ID' is not a parameter or variable or field of 'x'. If 'ID' is a property please add the FieldAlias or Storage attribute to it or declare it as a field's alias.
  2. Lafama
    Lafama avatar
    12 posts
    Member since:
    Oct 2009

    Posted 01 Jun 2010 Link to this post

    Anyone wiling to help. Surely how long does it take to reply to a problem (8 hours en counting i guess)

    ?????
    !!!!
  3. DevCraft banner
  4. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 03 Jun 2010 Link to this post

    Hello Lafama,

     From the exception message provided, it seems that you are using the old OpenAccess mapping approach with the Forward and Reverse Mapping wizards. In this kind of scenario which looks like forward mapping, the properties of the class need to be marked with a "FieldAlias" attribute. This attribute helps OpenAccess to resolve the property <-> field relation. Here is an example of what you could do with your class:

    public class X
    {
        private int id;
     
        [FieldAlias("id")]
        public int ID
        {
           get{ return this.id; }
        }
    }


    Greetings,
    Zoran
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 16 Jun 2010 Link to this post

    Zoran,

    Sorry to high-jack the thread, but I was searching for an answer to this problem.

    I note form your reply that you say "it seems that you are using the old OpenAccess mapping approach with the Forward and Reverse Mapping wizards". I wonder what you mean by the old OpenAccess Mapping approach.

    What approach should I be using?

    -- 
    Stuart
  6. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 18 Jun 2010 Link to this post

    Hi Stuart Hemming,

     Since Q1 2010 OpenAccess introduced a new Visual Designer which is intended to replace the old Forward and Reverse mapping wizards. At the moment it only fully supports Reverse mapping scenarios so you could use it if you are starting your project in a "database first" approach. I would suggest you to get more familiar with the Visual Designer by looking into the documentation that is installed with the product in .chm format. At the moment, the online documentation is not updated with the latest information so I would like to apologize in advance that there is no information regarding the designer in our online help, but you have to look into the installed one instead. We are doing our best into preparing the online version of the documentation and we promise it will be available soon on the web as well.

    Sincerely yours,
    Zoran
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner