GetComments

Vote:
 

Why is var result = CommentHandler.Instance.GetComments(reference, new UserAuthor(CurrentUser),......

and CommentCollection comments = CommentHandler.Instance.GetComments(reference, null,....

var result = from c in comments
where c.Author.ID == CurrentUser.ID
select c;

not returning the same number of rows?

(In my case is the first one not returning any rows.)

#55747
Dec 15, 2011 10:42
Vote:
 

Well, for one, the Author ID and user ID are not the same. So the match you get in your linq statement is false.

To get the user ID from an author you have to do somethign like this:

var userAuthor = c.Author as UserAuthor;

if (userAuthor != null)

{

var userId = userAuthor.User.ID;

// Do stuff

}

#55783
Dec 15, 2011 14:51
Vote:
 

Allright. c.Author.EntityId seems to be the same as userAuthor.User.ID thou.

Anyway still wondering about how to use the first statement, getComments for a certain user.

 

#55790
Dec 16, 2011 11:33
Vote:
 

Yes, as long as it is a user author (it may be a guest author for example).

You can use AuthorHandler.Instance.GetAuthors(IUser user) to get all author objects pointing to the users. Genreally I think there should be only one, which is reused if you have code that will new up a UserAuthor. Not sure about this though, I have never tried to get comments by author.

#55793
Dec 16, 2011 11:47
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.