This is a migrated thread and some comments may be shown as answers.

Linq where clause not working in Open access

4 Answers 232 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lafama
Top achievements
Rank 1
Lafama asked on 31 May 2010, 10:55 PM
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.

4 Answers, 1 is accepted

Sort by
0
Lafama
Top achievements
Rank 1
answered on 01 Jun 2010, 07:15 AM
Anyone wiling to help. Surely how long does it take to reply to a problem (8 hours en counting i guess)

?????
!!!!
0
Zoran
Telerik team
answered on 03 Jun 2010, 08:53 AM
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.
0
Stuart Hemming
Top achievements
Rank 2
answered on 16 Jun 2010, 12:38 PM
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
0
Zoran
Telerik team
answered on 18 Jun 2010, 12:16 PM
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
Tags
LINQ (LINQ specific questions)
Asked by
Lafama
Top achievements
Rank 1
Answers by
Lafama
Top achievements
Rank 1
Zoran
Telerik team
Stuart Hemming
Top achievements
Rank 2
Share this question
or