?
orus casino
?
bodog
?
ruleta
?
luckia
?
betano
?
sportium
?
spin casino
?
stakes
?
3 reyes
?
888
?
lottoland
?
coolbet
?
777 casino
?
gana777
?
betfair
?
bwin
?
yak casino
?
ivy casino
?
oddschecker
?
red casino
?
netbet
?
william hill
?
vip casino
?
rey casino
?
marathonbet
?
dafabet
?
sol casino
?
1bet
?
winland
?
bet777
?
parimatch
?
18bet
?
888casino
?
campobet
?
mostbet
?
ganabet
?
rushbet
?
betcris
?
betsson
?
lucky
?
novibet
?
winner
?
winpot
?
betmaster
?
betmexico
?
cancun
?
playcity
?
strendus
?
pokerstars
?
codere
?
caliente
?
fun88
?
bbrbet
?
1win
?
10bet
?
betway
?
pin up
?
spinbet
?
7cslot
?
pickwin
?
spin bet
?
mr fortune
?
w88
?
pragmatic
?
gamdom
?
crasher
?
jojobet
?
betmex
?
bcasino
?
foliatti
?
winner mx
?
bets 10
?
big bola
?
bet master
?
inbet
?
7slots
?
lucky day
?
m777
?
mexplay
?
luckydays
?
bet caliente
?
1x
?
plinko
Need
DNN Support
?
DeskPal.com
Learn DNN / DotNetNuke
Login
Subscribe to DNNCreative
Home
Subscribe
Training & Tutorials
Tutorials for Beginners
Tutorials for Administrators
Tutorials for Core Modules
Tutorials for Advanced Users
How to Build a Website in DotNetNuke
Skinning Tutorials
Module Development
Third Party Modules
Forum
Search
Search
Home
Subscribe
+
Training & Tutorials
Tutorials for Beginners
Tutorials for Administrators
Tutorials for Core Modules
Tutorials for Advanced Users
How to Build a Website in DotNetNuke
Skinning Tutorials
Module Development
Third Party Modules
Forum
You need to
Register
for free and
Login
to post a message in the forum.
Forum
Forums
Search Forum
Search
Advanced Search
Topics
Posts
Unanswered
Active Topics
Forums
>
DotNetNuke®
>
DotNetNuke® Questions
LinqToSQL IN Query
Last Post 05/28/2011 12:39 PM by
Joseph Craig
. 4 Replies.
Sort:
Oldest First
Most Recent First
Check this box to subscribe to this topic.
Prev
Next
You are not authorized to post a reply.
Author
Messages
Elgin Rogers
Nuke Active Member
Posts:22
05/27/2011 3:57 PM
To all: Thank you for your help:
In the standard DNN database there are the following tables: Roles, UserRoles, Users.
I have a DNN module where I would like to populate a ListBox control with all users that have a selected Role assigned to them. The role will be selected via an asp dropdownlist populated by the Roles table. I have the following code in the "on_selecting" event of the linq datasource:
protected void ldsUsers_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
var uRoleQuery = from uRole in db.UserRoles
where uRole.RoleID == Convert.ToInt32(ddlRoles.SelectedValue)
select new
{
uRole.UserID
};
var userQuery = from u in db.Users
where uRoleQuery.Contains(u.UserID)
select u;
e.Result = userQuery;
}
I am getting intellisense error on the uRoleQuery.Contains(u.UserID) line that says:
" The type arguments for method 'System.Linq.Queryable.Contains
(System.Linq.IQueryable
, TSource)' cannot be inferred from the usage. Try specifying the type arguments explicitly. "
Why? I'm not quite sure how to use the UserRoles table to cross reference to the userID in a subquery within LINQ.
Thank you for your help.
Elgin
Joseph Craig
DNN MVP
Posts:11667
05/27/2011 5:51 PM
Accepted Answer
DON'T! STOP!!
When you are working with DotNetNuke, you should use SQL only as a last resort. DotNetNuke has an extensive collection of classes and methods with which to interact with the framework and data. You should make it a point to get to know them and use them.
You can download a compiled help file from DotNetNuke.com that includes the entire framework. Look for the "Core API Help File" on the Codeplex page where you download your version of DotNetNuke.
From a post on the DotNetNuke forums:
Dim roleName As String = "Moderators"
Dim roleCtlr As New Security.Roles.RoleController
Dim objUserRoles As ArrayList = roleCtlr.GetUserRolesByRoleName(PortalId, roleName)
The object returned by the GetUserRolesByRoleName method is an arraylist of DotNetNuke.Entities.Users.UserRoleInfo objects which include UserId, Fullname, etc. as their members
The good news there is that you can then get UserInfo for each user. That includes everything available about the users, including profile properties. Doing that in SQL has some complications. Finally, if you use the provided methods, you'll insulate yourself against changes that do occur from time to time in the database structure.
Joe Craig,
Patapsco Research Group
Complete DNN Support
Elgin Rogers
Nuke Active Member
Posts:22
05/27/2011 10:59 PM
Joseph,
Thank you so much for keeping me from making a huge mistake. I will take your advice and study the classes thoroughly before proceeding with my project.
I had no idea.
Thanks again.
Elgin
Elgin Rogers
Nuke Active Member
Posts:22
05/28/2011 11:36 AM
Joseph,
I've started my studying of the DNN API and I can see where this is going to be very beneficial. Thank you again. I'm very excited about this discovery.
I have a couple of questions about my current topic. In your example, the method used is "GetUserRolesByRoleName" which "Gets the user in a role (as UserRole objects). Why not use the "GetUsersByRoleName" method, which "Gets the users in a role (as User objects) instead?
I see that both objects have the members I need to populate my Listbox - FullName or DisplayName and UserID. So what's the difference? Is one object more suitable than the other?
Also, at the top of your reply you said "... and extensive collection of classes and methods with which to interact with the framework and data." Would this include classes that would interact with - a)User tables I've added to the DNN database, and - b)a completely separate database that has several RELATED tables which is the data used in my application?
For this application, I had an experienced C# developer get me started with some basic reporting modules for reporting on SQL Data. They used all asp SqlDataSources and SelectCommands for the project. Are you saying that the API has classes and methods that can handle all of this?
Thank you for always giving good help and advice here too.
Elgin
Joseph Craig
DNN MVP
Posts:11667
05/28/2011 12:39 PM
You are right. GetUsersByRoleName is what I should have said. GetUsers is the right thing to use.
I don't think that there are generic methods to deal with "other" tables. If you were building a module using the DotNetNuke module design patterns, you would build data providers and methodes to interact with your data, and you could call them. See the book by Mitchel Sellers for details.
I do seem to recall that there are some Linq to SQL methods in the framework. Those should work with any SQL sources, given that you are using appropriate connection strings and data sources. You'll have to dig around in the framework to find these. I often find that a few minutes of Googling can point me in the right direction.
For general SQL reporting, and even some fancy things you should not forget the Form & List module, the Reports module and the XML module. All of those have some combination of data providers, visualizers, XLT possibilities, etc. There are some pretty good blog entries from Joe Brinkman and Stefan Cullman about some of this. Also, the new Razor host module. And, a guy named Armand Datema ("Nokiko") has been doing some really cool stuff with some of these modules. You'll have to Google to find him (also at 2dnn.com). He's presenting some talks at the upcoming European DotNetNuke meeting, and has promised some blogs after that.
Joe Craig,
Patapsco Research Group
Complete DNN Support
You are not authorized to post a reply.
Special Bonuses
--Subscriber Bonuses
--Readers Offers
Users Lounge
--Announcements
--DNN Creative Articles
--Everything Else
--Feedback, Suggestions and More
--Membership
--Site Review Please!
--Testimonials
--Podcasts
DotNetNuke®
--DotNetNuke® Questions
--Modules
--Modules - What's needed?
--Quick Tips
Hosting
--DotNetNuke® Hosting Providers
Skinning Toolkit
--Skinning Toolkit
UK DotNetNuke User Group
Forums
>
DotNetNuke®
>
DotNetNuke® Questions
Latest Forum Posts
Can you Run Xcode in Linux?
by Aman Singh
Can you Run Xcode in Linux?
Can you Run Xcode in Linux?
by Aman Singh
Can you Run Xcode in Linux?
Billed for subscription that was canceled
by Ryan
I was just billed for a subscription that was canc eled / inactivetive how do I get a refund for th
Meta Title and Meta Description are not showing properly
by DNN User
Hi, On my site the meta title and meta descriptions are not showing properly. It's showing the m
Search is not functioning properly
by DNN User
Site: https://www.prv-engineering.co.uk/search If I search any item only the 1st option under sea
Search is not functioning properly
by DNN User
Site: https://www.prv-engineering.co.uk/search If I search any item only the 1st option under sea
DNN Platform import site optio
by Melanie Weaver
Is it possible to import site template in DNN Platform 8.0? We have internal Evoq Content 8.1 tha
Events Module for DNN V5?
by Tugboat
Would anyone have a download link for the version 5.0.3 Events Module? Thanks!
"Ghost" TabID Number?
by Tugboat
Hi! I have a portal instance with multiple child portals and on one of the child portals, there i
RE: DNN Load Testing
by ayman sharkawy
Hi. Have you already implemented a site using the DNN . And how the performance of the site and its
Publish All Pages
by NSUOK
I'm using DNN Evoq Content Basic 8.2.0. When I make the HTML Pro module display on all pages, I h
Simpler profile needed in 9.2.2
by Donald
We are upgrading a DNN 4.8.4 site to DNN 9.2.2. On 4.8.4, the top bar shows the user’s name. If yo
How to link from dnnmodal popup to web site page?
by Donald
Hello all. I am using a dnnmodal.show popup. The popup works correctly, showing the content that I
RE: Document Collaboration
by Nick Davern
That feature would be super beneficial for our needs as well! Does anyone have an update as to if th
RE: DNN 9.2, how to set default theme?
by Andy Stephenson DNN Creative
you do that under "Manage/Themes". Note the highlight blue border around the default container and d
DNN 9.2, how to set default theme?
by Donald
Please disregard, found Manage Themes I cannot find how to set a default portal theme in DNN 9.2
RE: Looking for DataSprings Dynamic Forms
by Andy Stephenson DNN Creative
Your best chance would be to contact Chad Nash @ http://www.datasprings.com/
Looking for DataSprings Dynamic Forms
by Jakir HM
Looking for DataSprings Dynamic Forms 3.4 for DNN 4.x 5.x for my site (https://themasters2018s.com/)
RE: Help with Cycle Image Carousel not displaying images
by peter
I had the same problem with the Will Strohl Content Slider after upgrading to DNN 9.1 The above an
RE: Object reference not set to an instance of an object
by Andy Stephenson DNN Creative
Check this one might be useful: http://www.dnnsoftware.com/answers/im-tryin-to-move-my-site-to-pr
Used
By
Testimonials