func (mwoq *MessageWithOptionalsQuery) First(ctx context.Context) (*MessageWithOptionals, error) {
	nodes, err := mwoq.Limit(1).All(ctx)
	if err != nil {
		return nil, err
	}
	if len(nodes) == 0 {
		return nil, &NotFoundError{messagewithoptionals.Label}
	}
	return nodes[0], nil
}
First returns the first MessageWithOptionals entity from the query.
Returns a *NotFoundError when no MessageWithOptionals was found.
package ent
import (
	"context"
	"errors"
	"fmt"
	"math"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithoptionals"
	"entgo.io/contrib/entproto/internal/entprototest/ent/predicate"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type MessageWithOptionalsQuery struct {
	config
	limit      *int
	offset     *int
	unique     *bool
	order      []OrderFunc
	fields     []string
	predicates []predicate.MessageWithOptionals
	sql  *sql.Selector
	path func(context.Context) (*sql.Selector, error)
}
func (mwoq *MessageWithOptionalsQuery) Where(ps ...predicate.MessageWithOptionals) *MessageWithOptionalsQuery {
	mwoq.predicates = append(mwoq.predicates, ps...)
	return mwoq
}
func (mwoq *MessageWithOptionalsQuery) Limit(limit int) *MessageWithOptionalsQuery {
	mwoq.limit = &limit
	return mwoq
}
func (mwoq *MessageWithOptionalsQuery) Offset(offset int) *MessageWithOptionalsQuery {
	mwoq.offset = &offset
	return mwoq
}
func (mwoq *MessageWithOptionalsQuery) Unique(unique bool) *MessageWithOptionalsQuery {
	mwoq.unique = &unique
	return mwoq
}
func (mwoq *MessageWithOptionalsQuery) Order(o ...OrderFunc) *MessageWithOptionalsQuery {
	mwoq.order = append(mwoq.order, o...)
	return mwoq
}