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

Changes to Basics in Q1 2010

4 Answers 44 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Solomon
Top achievements
Rank 1
Solomon asked on 06 May 2010, 05:11 PM
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.

4 Answers, 1 is accepted

Sort by
0
Andreas
Top achievements
Rank 1
answered on 06 May 2010, 06:48 PM

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
0
Solomon
Top achievements
Rank 1
answered on 06 May 2010, 10:21 PM
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
0
Solomon
Top achievements
Rank 1
answered on 06 May 2010, 10:25 PM
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
0
Andreas
Top achievements
Rank 1
answered on 07 May 2010, 12:29 AM
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.
Tags
General Discussions
Asked by
Solomon
Top achievements
Rank 1
Answers by
Andreas
Top achievements
Rank 1
Solomon
Top achievements
Rank 1
Share this question
or