withfield orchard 1.4.2

2019-08-14 10:15发布

问题:

I'm new to orchard and am following http://skywalkersoftwaredevelopment.net tutorials.

ContentDefinitionManager.AlterPartDefinition(typeof(AddressPart).Name, p => p
            .Attachable(false)
            .WithField("Name", f => f.OfType(typeof(TextField).Name))
            .WithField("AddressLine1", f => f.OfType(typeof(TextField).Name))
            .WithField("AddressLine2", f => f.OfType(typeof(TextField).Name))
            .WithField("Zipcode", f => f.OfType(typeof(TextField).Name))
            .WithField("City", f => f.OfType(typeof(TextField).Name))
            .WithField("Country", f => f.OfType(typeof(TextField).Name))
            );

 SchemaBuilder.CreateTable("AddressRecord", t => t
            .ContentPartRecord()
            .Column<int>("CustomerId")
            .Column<string>("Type", c => c.WithLength(50))
            );

what does withfield really function in this case? why no createtable stuff to create real table field for addressrecord table ?

where are these "Name", "addressline1" supposed to be saved in database?

Thanks for your reading.

回答1:

It adds fields to the Address part. Fields are lighter weight ways to extend type in Orchard. They do not get stored in their own tables but rather are serialized as XML into a single column. This is why they are easier to create, but harder to query.