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

Enum support in OA linq query.

7 Answers 185 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.
Alexey
Top achievements
Rank 2
Alexey asked on 11 Nov 2008, 06:27 AM
I failed to use enum inside of linq query expression and get following error:

Telerik.OpenAccess.OpenAccessException : Field 'productType' on PersistentClasses.Product is not a reference to another PC class

.Where(product => product.ProductType == productType)
                .ToList()
                .AsReadOnly();

    public enum ProductType : int
    {
        Food = 0,
        Electronics
    }

        [FieldAlias("productType")]
        public ProductType ProductType
        {
            get { return productType; }
            set { productType = value; }
        }

PS: At first ProductType field was generated as int. So in database it has int type. I'm using SQL Server 2008.









7 Answers, 1 is accepted

Sort by
0
Alexey
Top achievements
Rank 2
answered on 13 Nov 2008, 07:58 AM
Any ideas how to fix it guys? In Linq To SQL it works fine.
0
Accepted
Thomas
Telerik team
answered on 13 Nov 2008, 02:07 PM
Hi Alexey,

yes, we fixed it; thanks for your report. Problem was an additional conversion the LINQ expression tree was having. At this point only PC type casts were expected. Unfortunately, there is currently no workaround without removing the enum.

Kind regards,
Thomas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alexey
Top achievements
Rank 2
answered on 13 Nov 2008, 02:24 PM
You mean that this fix will be included in the next release?
0
Thomas
Telerik team
answered on 14 Nov 2008, 02:41 PM
Hello Alexey,

yes, the next version will have the required changes. Thanks for reporting this issue.

Greetings,
Thomas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alexey
Top achievements
Rank 2
answered on 14 Nov 2008, 02:48 PM
That's great! Thanks =)
0
Ross Presser
Top achievements
Rank 1
answered on 12 May 2010, 04:35 PM
I got the same message, but this time the field is a char.  (Reverse mapped class, char(1) in database, Char in .NET).  Using release 2009.3.1119.2. Is this a known problem?

Dim acls = From a As ACL In scope.Extent(Of ACL)() Where a.[Group].Users.Contains(aUser) and a.allowOrDeny = "A"c

(The class is called ACL, and the char field is called allowOrDeny. VB.NET shown.)
0
Thomas
Telerik team
answered on 14 May 2010, 10:26 AM
Hi Ross,

the current version does not have this issue; can you give it a try? 

Sincerely yours,
Thomas
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
Alexey
Top achievements
Rank 2
Answers by
Alexey
Top achievements
Rank 2
Thomas
Telerik team
Ross Presser
Top achievements
Rank 1
Share this question
or