So, to take the the Person class

class Person{
    int Id{get;set;} //real column as we need to lookup on id
    string Name {get;set;} //mapped to a real column

    //all these properties I just want put into the json column
    string Address1 {get;set;}
    string Address2 {get;set;}

}


CREATE TABLE dbo.Person
(
        Id int NOT NULL,
        Name nvarchar(50) NOT NULL,
        /*other columns here */
        Json nvarchar(MAX) NULL,
        CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED (Id)
)

The idea is that I can add properties that aren't being used in
foreign key constraints or indexes without having to change my db
schema, similar to a document store.

On Jul 30, 5:55 pm, Fabio Maulo <[email protected]> wrote:
> Can you send a simple class and its persistent representation ?
> thanks.
>
>
>
> On Mon, Jul 26, 2010 at 6:49 AM, mcintyre321 <[email protected]> wrote:
> > I want to be able to add new properties to an entity without having to
> > define schema for them, and have them all persist to a single db
> > column.
>
> > Unless I'm mistaken about their capabilities, I'm not sure an
> > IUserType is what I'm after - I previously wrote an XML serialized
> > generic UserType before, but what that did was map 1 property -> 1 db
> > column. I want to map n properties to 1 column.
>
> > On Jul 23, 6:30 pm, Fabio Maulo <[email protected]> wrote:
> > > No Jason... it is very easy... IUserType
> > > Note: He said "map some properties of an entity"
>
> > > On Fri, Jul 23, 2010 at 1:23 PM, Jason Dentler <[email protected]
> > >wrote:
>
> > > > I'm sure you can do this with some seriously heavy lifting, like
> > writing a
> > > > custom persister, but it would be easier to map this to some field in
> > your
> > > > entity and then parse it.
>
> > > > On Fri, Jul 23, 2010 at 11:15 AM, mcintyre321 <[email protected]
> > >wrote:
>
> > > >> I've been wondering if its possible to have NH map some properties on
> > > >> an entity from a schema-free json (or xml) column
>
> > > >> e.g. map a db table like
> > > >> Id, Name, Json
> > > >> 1, Marmaduke, {address1: Windsor Castle, address2: London }
>
> > > >> to a class like
>
> > > >> class Person{
> > > >>    int Id{get;set;}
> > > >>    string Name {get;set;}
> > > >>    string Address1 {get;set;}
> > > >>    string Address2 {get;set;}
> > > >> }
>
> > > >> Is there a way to do this, or an extension point I could use to enable
> > > >> this?
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > Groups
> > > >> "nhusers" group.
> > > >> To post to this group, send email to [email protected].
> > > >> To unsubscribe from this group, send email to
> > > >> [email protected]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>>
> > > >> .
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/nhusers?hl=en.
>
> > > >  --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "nhusers" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > --
> > > Fabio Maulo
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> Fabio Maulo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to