Exemplo n.º 1
0
        public IApiFieldBuilder <TItem, TField> Field <TField>(Expression <Func <TItem, TField> > expression)
        {
            string originalName = ExpressionNameHelper.GetFullPropertyName(expression);

            var fieldModel = _model.Fields.FirstOrDefault(f => f.OriginalName == originalName)
                             ?? CreateNewFieldModel(originalName);

            var fieldBuilder = new EngineFieldBuilder <TItem, TField>(fieldModel, expression);

            if (fieldModel.Reader == null) // only models created above
            {
                fieldBuilder.AllowRead();
                fieldBuilder.AllowCollate();
            }

            return(fieldBuilder);
        }
Exemplo n.º 2
0
        public IApiIdentifierBuilder <TItem, TIdentifier> Identifier <TIdentifier>(Expression <Func <TItem, TIdentifier> > expression)
        {
            string originalName    = ExpressionNameHelper.GetFullPropertyName(expression);
            var    identifierModel = new ApiIdentifierModel <TItem>
            {
                Name = originalName
            };

            // TODO selecting same expression again, like with fields

            var identifierBuilder = new ApiIdentifierBuilder <TItem, TIdentifier>(identifierModel);

            identifierBuilder.AddExpression(expression);

            _model.Identifiers.Add(identifierModel);

            return(identifierBuilder);
        }