mongodb-user
[Arriba] [Todas las Listas]

Re: [mongodb-Usuario] Cómo para utilizar [BsonIgnoreIfNull] para un int

To: "mongodb-user@xxxxxxxxxxxxxxxx" <mongodb-user@xxxxxxxxxxxxxxxx>
Subject: Re: [mongodb-Usuario] Cómo para utilizar [BsonIgnoreIfNull] para un integer Tipo
From: Robert Stam <robert@xxxxxxxxxxx>
Date: Tue, 2 Feb 2016 15:20:09 -0600
Delivery-date: Tue, 02 Feb 2016 16:20:17 -0500
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group :list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe; bh=NsjwlTOqq+j5aITZkERvVmL6u0a1OUvYAQ0JNR3LEh0=; b=HgUHmlukq3xxdicjxuVjbVqW6dwQBb7lByfj0xPv3xMKKxPR6TEvhU2eP6k6JcRA/L lB/5ZTF067EgmHtxD8D0Fd3QU0JhK7h5IRD+IwoPb2I6ofu6rC+f67MZz7IbDbOspFe2 d8X9VPeN3CmkDwRNS3MrTVLwGRxo+KyZGM9A1EZoaaD8mgOS5A/peHDENp/V+113+FFv 3S36pR+qYOYD8P8kwhgfm/2UtKhVRATA63ES7tjfGxYoqh/oMCMYThd8JWyII3kPRUfv bBgLLFtVt0qJDHjA/Htc42Te+EqEIxbS6EWV9t1H82TEaAJb0kAL9N6xCKphoGivZ8HX 7gmg==
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mongodb.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group :list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe; bh=NsjwlTOqq+j5aITZkERvVmL6u0a1OUvYAQ0JNR3LEh0=; b=A7JOn290EkrB63729mX8cQVyPSE6QH6mcbd7nR9x9TpOqq7d3iABYGLEaTL9D3J34t Mxs/jLmgOAAaAfRCUrlUu2QxzbfDuJqtpWNN3Ia+JyCmIPO7gWMlhbsgqrCr2Bcf66of NqhRyAR9BWU0MC92soeHoMqAOhZWCmk+UoF8M=
Envelope-to: traductor@xxxxxxxxxxx
In-reply-to: <CAJCJWG1w9t9M1QW8=3n99CvUefK9jMB9dB2999Z9LYkex8TNTw@mail.gmail.com>
List-archive: <https://groups.google.com/group/mongodb-use>
List-help: <https://groups.google.com/support/>, <mailto:mongodb-user+help@googlegroups.com>
List-id: <mongodb-user.googlegroups.com>
List-post: <https://groups.google.com/group/mongodb-user/post>, <mailto:mongodb-user@googlegroups.com>
List-subscribe: <https://groups.google.com/group/mongodb-user/subscribe>, <mailto:mongodb-user+subscribe@googlegroups.com>
List-unsubscribe: <mailto:googlegroups-manage+1044811755470+unsubscribe@googlegroups.com>, <https://groups.google.com/group/mongodb-user/subscribe>
Mailing-list: list mongodb-user@xxxxxxxxxxxxxxxx; contact mongodb-user+owners@xxxxxxxxxxxxxxxx
References: <1b94c327-5937-45a8-8756-581e4fe89d8d@googlegroups.com> <CAJCJWG1w9t9M1QW8=3n99CvUefK9jMB9dB2999Z9LYkex8TNTw@mail.gmail.com>
Reply-to: mongodb-user@xxxxxxxxxxxxxxxx
Sender: mongodb-user@xxxxxxxxxxxxxxxx
Puedes también uso [*BsonIgnoreIfNull] con *nullable *ints:

    clase pública *C
        #default{^[*BsonIgnoreIfNull]
        público *int? F #get; conjunto; } // *int? En vez de *int
    }

el F no será *serialized si es *null (*i.*e. *HasValue Es falso).


En *Tue, *Feb 2, 2016 en 3:18 PM, Robert *Stam <robert@xxxxxxxxxxx> escribió:

> [*BsonIgnoreIfNull] es significado para ser utilizado con tipo de referencia (tipo que
> puede tener un *null valor).
>
> Puedes utilizar [*BsonIgnoreIfDefault] con *int valores si quieres. Si el *int
> el valor es 0 lo no será *serialized.
>
> En *Tue, *Feb 2, 2016 en 12:21 PM, Adrian *Lopez <*adrian3d.art@xxxxxxxxx>
> escribió:
>
>> *Hi, hay cualquier manera de utilizar  [*BsonIgnoreIfNull]]*stament en un *int campo de un
>> modelo? Desde *C# no deja para tener *null valores para *int variables, yo *cant
>> figura fuera. Consideraciones.
>>
>>  Clase pública *MyModel
>> #default{^[*BsonIgnoreIfNull
>>  público *int campo1 consigue;conjunto;}
>> }
>>
>> --
>> recibiste este mensaje porque eres *subscribed al *Google Grupos
>> "*mongodb-grupo"
>> de usuario.
>>
>> Para otro *MongoDB opciones de apoyo técnico, ve:
>> *http://www.mongodb.org/sobre/apoyo/.
>> ---
>> Recibiste este mensaje porque eres *subscribed al *Google Grupos
>> "*mongodb-grupo" de usuario.
>> A *unsubscribe de este grupo y la parón que recibe *emails de él, enviar un
>> *email a *mongodb-usuario+unsubscribe@xxxxxxxxxxxxxxxx.
>> A correo a este grupo, envía *email a *mongodb-user@xxxxxxxxxxxxxxxx.
>> Visita este grupo en *https://grupos.*google.*com/Grupo/*mongodb-usuario.
>> Para ver esta discusión en la visita de web
>> *https://grupos.*google.*com/*d/*msgid/*mongodb-Usuario/1*b94*c327-5937-45#uno8-8756-581*e4*fe89*d8*d%40*googlegroups.*com
>> <*https://Grupos.*google.*com/*d/*msgid/*mongodb-Usuario/1*b94*c327-5937-45#uno8-8756-581*e4*fe89*d8*d%40*googlegroups.*com?*utm_Medio=*email&*utm_fuente=*footer>
>> .
>> Para más opciones, visita *https://grupos.*google.*com/*d/*optout.
>>
>
>

-- 
Recibiste este mensaje porque eres *subscribed al *Google Grupos "*mongodb-grupo"
de usuario.

Para otro *MongoDB opciones de apoyo técnico, ve: *http://www.mongodb.org/sobre/apoyo/.
--- 
Recibiste este mensaje porque eres *subscribed al *Google Grupos "*mongodb-grupo" de usuario.
A *unsubscribe de este grupo y la parón que recibe *emails de él, enviar un *email a *mongodb-usuario+unsubscribe@xxxxxxxxxxxxxxxx.
A correo a este grupo, envía *email a *mongodb-user@xxxxxxxxxxxxxxxx.
Visita este grupo en *https://grupos.*google.*com/Grupo/*mongodb-usuario.
Para ver esta discusión en la visita de web *https://grupos.*google.*com/*d/*msgid/*mongodb-Usuario/*CAJCJWG2*K66*iZJwvRnkSZ_*OCgB%3*DBHs%2*BGuE1%2*BjFCg6*hbnZQwDWRw%40correo.*gmail.*com.
Para más opciones, visita *https://grupos.*google.*com/*d/*optout.
You can also use [BsonIgnoreIfNull] with nullable ints:

    public class C
    {
        [BsonIgnoreIfNull]
        public int? F { get; set; } // int? instead of int
    }

F won't be serialized if it is null (i.e. HasValue is false).


On Tue, Feb 2, 2016 at 3:18 PM, Robert Stam <robert@xxxxxxxxxxx> wrote:

> [BsonIgnoreIfNull] is meant to be used with reference types (types that
> can have a null value).
>
> You can use [BsonIgnoreIfDefault] with int values if you want. If the int
> value is 0 it won't be serialized.
>
> On Tue, Feb 2, 2016 at 12:21 PM, Adrian Lopez <adrian3d.art@xxxxxxxxx>
> wrote:
>
>> Hi, there's any way to use  [BsonIgnoreIfNull]]stament in a int field of
>> a model? Since C# don't allow to have null values for int variables, I cant
>> figure out. Regards.
>>
>>  public class MyModel
>> {
>> [BsonIgnoreIfNull
>>  public int field1 get;set;}
>> }
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "mongodb-user"
>> group.
>>
>> For other MongoDB technical support options, see:
>> http://www.mongodb.org/about/support/.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "mongodb-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
>> To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
>> Visit this group at https://groups.google.com/group/mongodb-user.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/mongodb-user/1b94c327-5937-45a8-8756-581e4fe89d8d%40googlegroups.com
>> <https://groups.google.com/d/msgid/mongodb-user/1b94c327-5937-45a8-8756-581e4fe89d8d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAJCJWG2K66iZJwvRnkSZ_OCgB%3DBHs%2BGuE1%2BjFCg6hbnZQwDWRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
<Anterior por Tema] Tema Actual [Siguiente por Tema>