Tuesday, August 24, 2010

Spanish Wording For Receptions

Nhibernate - the relationship one to many and a few cosmetic changes

Hi after quite a long break due to the holidays:) Today I decided a little bit to describe a very simplified model of the logic associated closely with the forum or entities, such as Category Forum, Forum, Topic, Post. In addition, describe a few cosmetic.


logic associated with the forum

Forum will consist of categories. They divide the whole forum partly related to each other thematically. Each categories can have multiple forums. The forums have included topics and have many posts. Currently, models are very simple. With the development of the project and increasing functionality will grow
Forum Categories Class: public class
ForumCategory: BaseEntity
public virtual IEnumerable {get \u0026lt;Forum> Forums ; set;}}
Class Forum:

public class Forum: BaseEntity
 {public virtual string Name {get; set;  } 

public virtual string Description { get; set; }

public virtual ForumCategory Category { get; set; }

public virtual IEnumerable<Topic> Topics { get; set; }
}
 Klasa Temat: 

public class Topic : BaseEntity
{
public virtual string Name { get; set; }

public virtual Forum Forum { get; set; }

public virtual IEnumerable<Post> Posts { get; set; }
}
Klasa Post:
 public class Post : BaseEntity 
{
public virtual string Name { get; set; }
Public virtual
Topic Topic {get; set;}}



Nhibernate - one to many relationships

As seen above in our simple model of entity pair relations: one to many. The Fluent Nhibernate maps these relationships by the method of References and hasMany. Re is the same as the method that the entity that is Hason has an object in a relationship. However hasMany means that the entity has a number of objects from a given relation. The combination of these two methods gives rise to many a relationship. Now a simple example, mapping one to many relationship: ForumCategory -> Forum
 
public class ForumCategoryMap: ClassMap \u0026lt;ForumCategory>
{
Public ForumCategoryMap () {

Id (p => p.Id). GeneratedBy.Guid ();
Map (p => p.Name). Not.Nullable (.) Length (256 ); hasMany (p => p.Forums);

}}
 
And here we have the other end of our relationship that is a class forum: public class

ForumMap: ClassMap \u0026lt;Forum>
{
public ForumMap () {

Id (p => p.Id). GeneratedBy.Guid ();

Map (p => p.Name). Not.Nullable (). Length ( 256);
Map (p => p.Description). Not.Nullable (.) Length (256);
References (p => p.Category);
hasMany (p => p.Topics);
}} 


As can be seen in a very simple manner by means of Fluent Nhibernate we can create one to many relationships.

In addition to these changes I introduced the basic layout of the forum. Removed commandy. Their roles now Przejma DataTransferObjecty. Podmieniłem client-side validation of the standard Microsoft on jQuery. This required a download MVC Futures and substitution in views instead MicrosoftMvcValidation.js MicrosoftMvcJQueryValidation.js file.


0 comments:

Post a Comment