I. Creating an update DDL
nhibernate.config configuration file
<?xml version= "1.0" encoding= "Utf-8"?>
Model class Library is as follows:
Blog.cs class and Blog.hbm.xml entity mapping files
public class Blog
{public
blog ()
{
Tags = new hashset<tag> ();
Users = new hashset<user> ();
Posts = new hashset<post> ();
SecurityKey = Guid.NewGuid ();
}
public virtual int Id {get; set;}
Public virtual Guid SecurityKey {get; set;}
Public virtual icollection<post> Posts {get; set;}
Public virtual Icollection<user> the Users {get; set;}
Public virtual icollection<tag> Tags {get; set;}
[Field]
Public virtual string Title {get; set;}
[Field]
Public virtual string Subtitle {get; set;}
Public virtual string Logoimage {get; set;}
Public virtual bool Allowscomments {get; set;}
Public virtual DateTime Createdat {get; set;}
}
<?xml version= "1.0" encoding= "Utf-8"?>
Category.cs class and Category.hbm.xml entity mapping files
public class Category
{public
Category ()
{
Posts = new hashset<post> ();
}
Public virtual string Name {get; set;}
public virtual int Id {get; set;}
Public virtual icollection<post> Posts {get; set;}
}
<?xml version= "1.0" encoding= "Utf-8"?>
Comment.cs class and Comment.hbm.xml entity mapping files
public class Comment {public virtual int Id {get; set;}
Public virtual post post {get; set;}
Public virtual string Name {get; set;}
Public virtual string Email {get; set;}
Public virtual string Homepage {get; set;}
public virtual int Ip {get; set;}
Public virtual string Text {get; }
<?xml version= "1.0" encoding= "Utf-8"?>
Post.cs class and Post.hbm.xml entity mapping files
First we're going to add some nhibernate.search attribute declarations to the NHibernate entity object here about Full-text indexing. I wonder if this will support the configuration of XML instead of modifying the original object code. Friends who have used lucene.net may find that these logos, in fact, are directly targeted at fields when not using NHibernate. And now it's just a property of a business object. In this case, the data is automatically indexed when it is added or changed, but when the data is deleted,
The index is also automatically updated without human intervention.
[Indexed] public class Post {public post () {Tags = new hashset<tag> ();
Categories = new hashset<category> ();
Comments = new hashset<comment> ();
[DocumentID] public virtual int Id {get; set;}
[indexedembedded] public virtual blog Blog {get; set;}
[indexedembedded] public virtual user user {get; set;}
[Field] public virtual string Title {get; set;}
[Field] public virtual, string Text {get; set;}
[Field] public virtual DateTime Postedat {get; set;}
Public virtual icollection<comment> Comments {get; set;} Public virtual Icollection<catEgory> Categories {get; set;}
Public virtual icollection<tag> Tags {get; set;} }
<?xml version= "1.0" encoding= "Utf-8"?>
ReadOnlyBlog.cs class and ReadOnlyBlog.hbm.xml entity mapping files
public class Readonlyblog
{public
virtual int Id {get; set;}
Public virtual string Title {get; set;}
}
<?xml version= "1.0" encoding= "Utf-8"?>
Tag.cs class and Tag.hbm.xml entity mapping files
public class Tag
{public
virtual int Id {get; set;}
Public virtual object Entity {get; set;}
Public virtual string Name {get; set;}
}
<?xml version= "1.0" encoding= "Utf-8"?>
User.cs class and User.hbm.xml entity mapping files
public class User:iuser
{public
User ()
{
Posts = new hashset<post> ();
Blogs = new hashset<blog> ();
}
Public virtual icollection<blog> Blogs {get; set;}
Public virtual icollection<post> Posts {get; set;}
public virtual int Id {get; set;}
Public virtual byte[] Password {get; set;}
[