Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Linq - IQueryable - VB.net QuestionLinq - IQueryable - VB.net Question
Previous
 
Next
New Post
1/2/2009 3:13 PM
 

I have two functions that are very similar to each other.

FUNCTION A - get tabs starting with partticular alphabet (KeyChr)

Public Function LtQTabs(ByVal KeyChr As String) As IQueryable

Dim dx As New BlahBlah.LtQDataContext

Dim q = From o In dx.Tabs _
Where o.PortalID IsNot Nothing _
And o.PortalID = PortalSettings.ActiveTab.PortalID _
And o.TabID <> PortalSettings.AdminTabId _
And o.IsDeleted = False _
And (o.ParentId <> PortalSettings.AdminTabId Or o.ParentId Is Nothing) _
And o.TabName.StartsWith(KeyChr) _
And o.IsVisible = True _
Select o.TabID, o.TabName _
Order By TabName _
Take (1000)

Return q

End Function

Function B - get all tabs starting with anything but alphabet.

Public Function LtQTabsExt() As IQueryable

Dim dx As New BlahBlah.LtQDataContext

Dim q = From o In dx.Tabs _
Where p.RoleID = -1 _
And o.PortalID IsNot Nothing _
And o.PortalID = PortalSettings.ActiveTab.PortalID _
And o.TabID <> PortalSettings.AdminTabId _
And o.IsDeleted = False _
And (o.ParentId <> PortalSettings.AdminTabId Or o.ParentId Is Nothing) _
And o.TabName.Substring(0, 1) < "a" _
And o.IsVisible = True _
Select o.TabID, o.TabName _
Order By TabName _
Take (1000)

Return q

End Function

As you can see, Function A and B are awefully similar.  Right now, I just have them separately. Is there anyway to make them into one function? i

I've been stuck with this almost 4 days. Any hints would be appriiciated.

 

 
New Post
1/3/2009 5:41 AM
 

Tak,

you need either an additional (optional) parameter, e.g. "needMatch As boolean" and may differenciate appropriately:

AndAlso ((needMatch andAlso o.TabName.StartsWith(KeyChr)) _
 OrElse (not NeedMatch andAlso o.TabName.Substring(0, 1) < "a"))

another option would be to use a special KeyChr for the second solution, e.g. Chr(0).


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
1/3/2009 10:26 PM
 

Thank you! Sebastian

That worked perfectly. I passed the string  "Others" as KeyChr and did the boolean solution within the function just like you showed me above.

Did I say Thank you? Thank you! You finally saved me from my 5 days stuck lol

 

 
New Post
1/4/2009 6:57 AM
 

glad I was able to help you


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Linq - IQueryable - VB.net QuestionLinq - IQueryable - VB.net Question


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out