Exclude() public method

Adds one or more field names to be excluded from the results.
public Exclude ( ) : FieldsBuilder
return FieldsBuilder
        private static FieldsBuilder ParseProjection(string projection)
        {
            var fields = new FieldsBuilder();

            if (String.IsNullOrEmpty(projection))
                return fields;

            var projectionDocument = BsonSerializer.Deserialize<BsonDocument>(projection);

            foreach (var element in projectionDocument)
            {
                var value = element.Value;

                if (value.IsBoolean && value.AsBoolean || value.IsInt32 && value.AsInt32 != 0)
                {
                    fields.Include(element.Name);
                }
                else if (value.IsBoolean && !value.AsBoolean || value.IsInt32 && value.AsInt32 == 0)
                {
                    fields.Exclude(element.Name);
                }
                else
                {
                    throw Errors.InvalidProjectionFormat();
                }
            }

            return fields;
        }
Example #2
0
 PlayerExAccess()
     : base("PlayerEx")
 {
     excludeFields = new FieldsBuilder();
     excludeFields.Exclude("Ver", "Modified");
 }