Why is var result = CommentHandler.Instance.GetComments(reference, new UserAuthor(CurrentUser),......
and CommentCollection comments = CommentHandler.Instance.GetComments(reference, null,....
var result = from c in commentswhere c.Author.ID == CurrentUser.IDselect c;
not returning the same number of rows?
(In my case is the first one not returning any rows.)
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
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.
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.