I'm struggleing a bit with a stored procedure to fetch all members of Umbraco including their properties.
What I'm doing now is:
BEGIN
SET NOCOUNT ON;
DECLARE @memberId INT
SELECT Member.nodeId AS mId, Member.Email AS Email, Property.Alias AS Alias, ISNULL(CONVERT(VARCHAR, PreValues.dataInt), PreValues.dataNvarchar) AS Data, PreValues.dataNtext
FROM cmsMember Member
INNER JOIN cmsPropertyData PreValues ON PreValues.contentNodeId = Member.nodeId
INNER JOIN cmsPropertyType Property ON Property.id = PreValues.propertytypeid
INNER JOIN cmsMember2MemberGroup mg ON mg.Member = Member.nodeId
ORDER BY nodeID, Property.Alias
END
While this gives me the "right" amount of data it doubles the output because of the joins, so every email address is output for every property.alias there is.
Has anyone figured out a better way to do this? :-) I'm aware that your should'nt be querying the database directly, but as we all know: the Member.GetAll() method is very slow when the memberbase is big.
Any help and/or input on this is greatly appreciated!
I am in fact on a 4.7.1 install. But isn't Examine only for searching a criteria? It is possible to pull *all* members just from a single call to Examine?
Do you need the data in your website, or do you need it to export the member data to csv. In case of the last option you might want to checkout Memberexport. http://our.umbraco.org/projects/website-utilities/memberexport It's lightning fast and free for up to 200 members, so you can try it.
Yes you can i am fairly you can certain the field __IndexType will have member in it. Create an index and then look into it using luke http://www.getopt.org/luke/ your query would then be something like
var criteria = searcher.CreateSearchCriteria(IndexTypes.Member);
then further refine the query to pull back members based on certain type? I dont have member index handy if you can paste fields in member index only need field names then i can help further refine the query for you.
Here's another suggestion... all the members (and their data) are also stored in the cmsContentXml table which should make for a simpler query:
DECLARE @nodeObjectType AS UNIQUEIDENTIFIER SET @nodeObjectType ='39EB0F98-B348-42A1-8662-E7EB18487560' -- MEMBER
SELECT * FROM cmsContentXml WHERE nodeId IN ( SELECT id FROM umbracoNode WHERE nodeObjectType = @nodeObjectType AND trashed = 0 )
The above will return a row for each member containing an XML fragment with all their member data.
If you have uComponents installed, the following uQuery API call might also be useful, as it'll return an XML document containing all members - this should be fast, as it's one db hit to get the complete XML.
How about this, i have just googled and found this forum, just got an idea how to query members along with properties, this is what iv'e got instead of using INNER JOIN posted by bo mortensen ive just do tweak on the query =>
DECLARE @memberId INT
SELECT Member.nodeId AS mId, Member.Email, Property.Alias, ISNULL(CONVERT(VARCHAR, PreValues.dataInt), PreValues.dataNvarchar) AS Data,
PreValues.dataNtext
FROM cmsMember AS Member LEFT OUTER JOIN
cmsPropertyData AS PreValues ON PreValues.contentNodeId = Member.nodeId LEFT OUTER JOIN
cmsMember2MemberGroup AS mg ON mg.Member = Member.nodeId LEFT OUTER JOIN
cmsPropertyType AS Property ON Property.id = PreValues.propertytypeid
How about this, i have just googled and found this forum, just got an idea how to query members along with properties, this is what iv'e got instead of using INNER JOIN posted by bo mortensen ive just do tweak on the query =>
DECLARE @memberId INT
SELECT Member.nodeId AS mId, Member.Email, Property.Alias, ISNULL(CONVERT(VARCHAR, PreValues.dataInt), PreValues.dataNvarchar) AS Data,
PreValues.dataNtext
FROM cmsMember AS Member LEFT OUTER JOIN
cmsPropertyData AS PreValues ON PreValues.contentNodeId = Member.nodeId LEFT OUTER JOIN
cmsMember2MemberGroup AS mg ON mg.Member = Member.nodeId LEFT OUTER JOIN
cmsPropertyType AS Property ON Property.id = PreValues.propertytypeid
Stored Procedure to get all members
Hi all,
I'm struggleing a bit with a stored procedure to fetch all members of Umbraco including their properties.
What I'm doing now is:
While this gives me the "right" amount of data it doubles the output because of the joins, so every email address is output for every property.alias there is.
Has anyone figured out a better way to do this? :-) I'm aware that your should'nt be querying the database directly, but as we all know: the Member.GetAll() method is very slow when the memberbase is big.
Any help and/or input on this is greatly appreciated!
Thanks a lot in advance.
- Bo
Bo,
Which version of umbraco are you using? If >4.5 then use examine to pull back all members and data it will be lightening quick.
Regards
Ismail
Hi Ismail,
Thanks a lot for your input!
I am in fact on a 4.7.1 install. But isn't Examine only for searching a criteria? It is possible to pull *all* members just from a single call to Examine?
Thanks again, much appreciated!
- Bo
Do you need the data in your website, or do you need it to export the member data to csv. In case of the last option you might want to checkout Memberexport. http://our.umbraco.org/projects/website-utilities/memberexport It's lightning fast and free for up to 200 members, so you can try it.
Cheers,
Richard
Bo,
Yes you can i am fairly you can certain the field __IndexType will have member in it. Create an index and then look into it using luke http://www.getopt.org/luke/ your query would then be something like
var criteria = searcher.CreateSearchCriteria(IndexTypes.Member);
then further refine the query to pull back members based on certain type? I dont have member index handy if you can paste fields in member index only need field names then i can help further refine the query for you.
Regards
Ismail
Hi Richard,
No, "sadly" I have to display the data on the website. Great suggestion however! :)
- Bo
@Ismail: thanks a lot! :-) I'll try to create the index then and see how it comes out.
Bo,
Ok i found an old index with members and in there you have field __NodeTypeAlias which is the type of member so then your query would be
var criteria = searcher.CreateSearchCriteria(IndexTypes.Member);
IBooleanOperation query = criteria.NodeTypeAlias("useralias");
//if you have more than one type of member
query = query.Or().Field("__NodeTypeAlias","anotheralias")
obviously replace useralias and anotheralias with your aliases
Regards
Ismail
Hi Ismail,
Thanks again! :-)
Haven't used Examine that much really, so I'm a bit insecure here.
As far as I can see the .Search() method takes a criteria parameter, so what exactly is the query variable used for in your case? :-)
Also, I'm getting a YSOD nullpointer exception on this line:
Doublechecked the name of my searchproviders name and it looks alright.
- Bo
Hi Bo,
Here's another suggestion... all the members (and their data) are also stored in the cmsContentXml table which should make for a simpler query:
The above will return a row for each member containing an XML fragment with all their member data.
If you have uComponents installed, the following uQuery API call might also be useful, as it'll return an XML document containing all members - this should be fast, as it's one db hit to get the complete XML.
HTH,
Hendy
ok try the following
BaseSearchProvider searcher = ExamineManager.Instance.SearchProviderCollection["MemberSearcher"];
var criteria = searcher.CreateSearchCriteria(IndexTypes.Member);
var results = searcher.Search(criteria);
Regards
Ismail
Jeeeeeeeeezzzzz!!
This does just what I want: <xsl:for-each select="ucomponents.members:GetMembersByType('MyMemberType')">
uComponents to the rescue! Seems to be really fast aswell :-)
However, I'm certainly going to have a look at Examine anyway since I also have to make some advanced searching on the site (and on members..)
So, thanks so much both Hendy and Ismail - you guys rock! Be sure to poke me at CG12 for a beer ;-)
All the best,
- Bo
How about this, i have just googled and found this forum, just got an idea how to query members along with properties, this is what iv'e got instead of using INNER JOIN posted by bo mortensen ive just do tweak on the query =>
DECLARE @memberId INT
SELECT Member.nodeId AS mId, Member.Email, Property.Alias, ISNULL(CONVERT(VARCHAR, PreValues.dataInt), PreValues.dataNvarchar) AS Data,
PreValues.dataNtext
FROM cmsMember AS Member LEFT OUTER JOIN
cmsPropertyData AS PreValues ON PreValues.contentNodeId = Member.nodeId LEFT OUTER JOIN
cmsMember2MemberGroup AS mg ON mg.Member = Member.nodeId LEFT OUTER JOIN
cmsPropertyType AS Property ON Property.id = PreValues.propertytypeid
ORDER BY mId, Property.Alias
===========================
AND IT LISTED AS FOLLOWS
===========================
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
How about this, i have just googled and found this forum, just got an idea how to query members along with properties, this is what iv'e got instead of using INNER JOIN posted by bo mortensen ive just do tweak on the query =>
DECLARE @memberId INT
SELECT Member.nodeId AS mId, Member.Email, Property.Alias, ISNULL(CONVERT(VARCHAR, PreValues.dataInt), PreValues.dataNvarchar) AS Data,
PreValues.dataNtext
FROM cmsMember AS Member LEFT OUTER JOIN
cmsPropertyData AS PreValues ON PreValues.contentNodeId = Member.nodeId LEFT OUTER JOIN
cmsMember2MemberGroup AS mg ON mg.Member = Member.nodeId LEFT OUTER JOIN
cmsPropertyType AS Property ON Property.id = PreValues.propertytypeid
ORDER BY mId, Property.Alias
===========================
AND IT LISTED AS FOLLOWS
===========================
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
is working on a reply...