This is my property which i am returning back from a anonymous function:
var ret = new
{
TagName = String.Join( ",", post.Tags.Select( t => t.TagName ) )
};
Here, post have many-to-many relationship with tag means a post can have multiple tags.
I want to null check here, if there is any tag then return back comma separated otherwise return empty string.
So far, I was trying many ways to null check like this but not getting exact syntax:
TagName = String.Join( ",", post.Tags.Select( t => t.TagName ) + ( post.Tags != null ? '' ) )
in case of simple string, i can get it like this:
alert( post.username != null ? ' ' + post.username : '') )