COUNT() is not available when I explicitly cast to IQueryable
-
mercoledì 7 marzo 2012 15:10
I have a DataAccess project that we have started converting to use linq.
right now we have functions like this,
Public Function GetBulletPoints() As System.Linq.IQueryable Dim bulletPoint = From bp In db.TblproductBulletPoints _ Where bp.displaySku.Equals(productParentSku) Order By bp.bp_order Return bulletPoint End FunctionIf I do not specify the return type I can use GetBulletPoints.Count(), but when the type is specified, I can just loop through the data. I loose a lot of the capabilities that are available when the return type is not specified.
Am I used the wrong return type, or can I not specify a return type and have all these capabilities available?
Tutte le risposte
-
mercoledì 7 marzo 2012 17:06
Hi RobinBones;
Your issue is that you are using the IQueryable interface type and you should be using the generic type IQueryable(Of TblproductBulletPoint) which has many more supported functions so change you function to this :
Public Function GetBulletPoints() As System.Linq.IQueryable(Of TblproductBulletPoint) Dim bulletPoint = From bp In db.TblproductBulletPoints _ Where bp.displaySku.Equals(productParentSku) Order By bp.bp_order Return bulletPoint End Function
That should correct your issue.Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".- Proposto come risposta JA Reyes - MCPD giovedì 8 marzo 2012 08:24
- Contrassegnato come risposta Allen Li - AI3Microsoft Contingent Staff, Moderator lunedì 12 marzo 2012 02:15

