Enum support in OA linq query.

8 posts, 1 answers
  1. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 11 Nov 2008 Link to this post

    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.









  2. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 13 Nov 2008 Link to this post

    Any ideas how to fix it guys? In Linq To SQL it works fine.
  3. DevCraft banner
  4. Answer
    Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 13 Nov 2008 Link to this post

    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.
  5. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 13 Nov 2008 Link to this post

    You mean that this fix will be included in the next release?
  6. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 14 Nov 2008 Link to this post

    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.
  7. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 14 Nov 2008 Link to this post

    That's great! Thanks =)
  8. Ross Presser
    Ross Presser avatar
    30 posts
    Member since:
    Dec 2008

    Posted 12 May 2010 Link to this post

    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.)
  9. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 14 May 2010 Link to this post

    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.
Back to Top
DevCraft banner