If field is not null

@*
-------------------------------------------------
IF THE FIELD IS AN IMAGE AND YOU JUST WANT ONE
-------------------------------------------------
*@

@if (item.GetFiles("PrimaryImage").Count==1) {
    <a href="@item["Link"]"><img src="@item.GetFiles("PrimaryImage")[0].Url?width=231&height=129&mode=crop" />
        @item["Title"]
    </a>
}


@*
-------------------------------------------------
IF IT'S JUST A BASIC FIELD. IN THIS EXAMPLE, THERE IS A CHECK FOR THE SUMMARY FIELD AND IF IT IS NULL THEN THE BODY IS LOADED
-------------------------------------------------
*@

@if(!item.IsDBNull("Summary")){
    @item["Summary"]
}
else{
    @BRT.Raw(item.GetString("Body").Summarize(200))
}


@*
-------------------------------------------------
IF YOU ARE CHECKING RELATED VIEWS, THEN LOOPING THROUGH THEM. THIS IS A BLOG POST AND GETTING RELATED AUTHORS
-------------------------------------------------
*@

@if (!item.IsDBNull("Authors")) {

    @foreach(EngineRecord author in item.GetRecordList("Authors")) {          
        if (author.GetFiles("PrimaryImage").Count > 0) {
            <img class="img-circle" src="@author.GetFiles("PrimaryImage")[0].Url?width=50&height=50&mode=crop" />
        }
        <span>
            @if(!author.IsDBNull("FirstName")){
                <a href="/authordetail/@author.Href">@author["FirstName"] @author["LastName"]</a>
            }
        </span>
    }
}