Fluent nhiberante (fnt) RC 1.0 has been released last week. Many of the items are discarded, some methods are improved, and some names are more appropriate. Although not perfect, however, we have already done a very well-developed job. If you find bugs or do not find the corresponding method, you can go to fluent googlegroups to post them and fnt author James Gregory will reply in a timely manner.
Fluent nhib1_release notes 1.0: http://wiki.fluentnhibernate.org/Release_notes_1.0
Fnt ing can be divided into fluent mapping (manual) and auto mapping (automatic). I have been using the manual method in my "fluent series, I think the corresponding good control also allows me to better learn nhib.pdf at the same time.
Fluent Mapping
1. modify some method names: It is relatively simple to change some tedious method names without losing their meaning.
Withlengthof-> Length
Columnname-> Column
Withtablename-> table
Actually, there are a lot more. I believe you can still see it at a Glance. If you don't find it, you can go to googlegroups for help.
2. The setattribute method is discarded: Because the fnt of the previous versions are not complete enough, many attributes of nhib.pdf are not supported. Therefore, the author left this method, so that developers can customize some attributes. This time, they completely dropped the setattribute method and relied entirely on the fluent Method for object ing. Therefore, I do not know how to map many features. However, you can still ask googlegroups for help, we strongly recommend that you add it to favorites for your own development.
3. Separation of subclass ing: before RC, we only need to map subclass and joinsubclass to the parent class, however, this practice is no longer advocated in the RC version. We need to separate the ing. I believe this practice is good and at least can be very clear about our own ing, it will not look as bad as before, huh, huh.
In RC, The ing between subclass and joinsubclass must inherit subclassmap <t>. Many Attributes and methods are the same as classmap <t>. They have their own attributes and methods, for example, the discriminatorvalue (string value) method is amazing. If this method is available, it will be mapped to the subclass tag. If not, it will be mapped to the join-subclass tag.
Before:
Public classPersonmap:Classmap<Person> {PublicPersonmap (){// Mapping person propertyDiscriminatesubclassesoncolumn <man> ("Type"). Subclass <man> (person. Man, S => {// Mapping man property}). Subclass <woman> (person. Woman, S => {// Mapping woman Property}); Setattribute ("Discriminator-value","Not null");}}
RC version:
public class personmap : classmap
{< span style =" color: blue "> Public personmap () {
// mapping person property discriminatesubclassesoncolumn
(
" type ", person. man) }}< span style = "color: Blue"> public class
manmap : subclassmap
{< span style = "color: Blue"> Public manmap () {discriminatorvalue (
" 0 ");
// mapping man property }< span style =" color: Blue "> public class
womanmap : subclassmap
{< span style =" color: Blue "> Public womanmap () {discriminatorvalue (
"0" );
// mapping woman property }
Maybe you didn't want to accept this method at the beginning. I started with it, But I gradually realized that this benefit is not only in terms of expansion, in addition, it is better to maintain and read data than the original method. Don't you think? The discriminatorvalue (string value) method is not perfect. If our identifier is of the string type, it is okay, but I have to hard-encode the enumeration type like mine.
Auto Mapping
1. Rename the static entry point:
Autopersistencemodel. mapentitiesfromassemblyof <t>
->
Automap. assemblyof <t>
I feel like I understand it even more after I rename it. Because I have never used automapping, I can only briefly talk about it.
2. Component ing:
Automap. assemblyof <person> (). Where (type => type. namespace. endswith ("Domain ");
->
. Setup (S => S. iscomponenttype = type => type = typeof (Address ))
I can understand what it means, but I have never tried it. I don't want to comment on it. If you are interested, read the details.
3. Ignore attributes (ignoreproperty). This is good. In the past, when we automatically mapped each attribute, whether or not we wanted to map it, we can use the following in the RC version:Code, Ignore these attributes without ing, very good, like one. Code:
. Fortypesthatderivefrom <shelf> (MAP => {map. ignoreproperty (x => X. yourproperty );});
For more information, see.
Summary
In fact, there are still some content, but I am not very good at English and do not understand it very well. It is probably because of some constraints and rules. I am not very good at it. I will wait for your help.
This RC version, there are a lot of highlights, but the document is not very comprehensive, you can go to googlegroups for help, you can also find your own http://wiki.fluentnhibernate.org, in general, has become more and more humane, however, there are still many shortcomings. I believe that some problems will be solved in the next version. continue to pay attention to them ....