Changes to Basics in Q1 2010

Thread is closed for posting
5 posts, 0 answers
  1. Solomon
    Solomon avatar
    17 posts
    Member since:
    Feb 2008

    Posted 06 May 2010 Link to this post

    Hello,

    I am surprisingly having difficulty with my existing code after upgrading to Q1 2010. I have been using very general query functionality that seems to be broken after I upgrade. Most of this seems to be centered around the absence of Telerik.OpenAccess.Query namespace. 

    Can someone tell me the equivalent of the following code in VS2010?

    public static Customer GetCustomerByEmailAddress(string emailAddress) 
            { 
                IObjectScope objectScope = ObjectScopeProvider.ObjectScope(); 
     
                IObjectScopeQuery<Customer> customers = from x in objectScope.Extent<Customer>() 
                                                        where x.EmailAddress == emailAddress.ToLower() 
                                                        select x; 
     
                if (customers.ToList().Count > 0) 
                { 
                    return customers.ToList()[0]; 
                } 
     
                return null
            } 

    This would probably open alot of doors for me just to see this working. I am dead in the water right now.
  2. Andreas
    Andreas avatar
    5 posts
    Member since:
    Jul 2009

    Posted 06 May 2010 Link to this post


    Hello Solomon,

    An error message would help but my first guess would be have you included the Telerik.OpenAccess.35.Extensions assembly?
    If you have upgraded to .NET 4 you will also need Telerik.OpenAccess.40.Extensions
  3. Solomon
    Solomon avatar
    17 posts
    Member since:
    Feb 2008

    Posted 06 May 2010 Link to this post

    I am getting the following compile error.

    • The type or namespace name 'IObjectScopeQuery' could not be found (are you missing a using directive or an assembly reference?

    I have references to Telerik.OpenAccess.35.Extensions but that does not seem to fix the problem. I have see other places where this was suggested, but no luck. 

    I am also importing System.Linq now where I did not have to do this in earlier versions of OpenAccess. No big deal.

    I am still running 3.5.

    Thanks for you help thus far!

    Sol
  4. Solomon
    Solomon avatar
    17 posts
    Member since:
    Feb 2008

    Posted 06 May 2010 Link to this post

    Just using this compiles. I will let you know how it behaves at runtime...

    public static Customer GetCustomerByEmailAddress(string emailAddress) 
            { 
                IObjectScope objectScope = ObjectScopeProvider.ObjectScope(); 
     
                IQueryable<Customer> customers = from x in objectScope.Extent<Customer>() 
                                                        where x.EmailAddress == emailAddress.ToLower() 
                                                        select x; 
     
                if (customers.ToList().Count > 0) 
                { 
                    return customers.ToList()[0]; 
                } 
     
                return null; 
            } 

    Thanks.

    Sol
  5. Andreas
    Andreas avatar
    5 posts
    Member since:
    Jul 2009

    Posted 06 May 2010 Link to this post

    for arrays I do this

    var res = from x ...
    res.ToList<ObjectType>();

    I have checked IObjectScopeQuery you are right you must use IQueryable
    because Telerik did make some internal changes.

    But I think the more generic way with a none declared type using the var keyword should always be safe.
Back to Top