title: Delete on Many to Many Relationship using Fluent Nhibernate
body: <p>User Class</p>
  
  <pre><code>public class User
      {
          public virtual Guid UserID { get; set; }
  
          public virtual string UserName { get; set; }
  
          public virtual string Password { get; set; }
  
          public virtual string FullName { get; set; }
  
          public virtual string Email { get; set; }
  
          public virtual TimeSpan LastLogin { get; set; }
  
          public virtual bool IsActive { get; set; }
          public virtual DateTime CreationDate { get; set; }
          public virtual IList&lt;Role&gt; Roles { get; set; }
  
          public User()
          {
              Roles = new List&lt;Role&gt;();
  
          }
          public virtual void AddRoles(Role role)
          {
              role.Users.Add(this);
              Roles.Add(role);
          }
      }
  </code></pre>
  
  <p>Role Class</p>
  
  <pre><code>public class Role
      {
  
          public virtual int? RoleID { get; set; }
  
          public virtual string RoleName { get; set; }
          public virtual bool IsActive { get; set; }
  
          public virtual string Description { get; set; }
          public virtual IList&lt;User&gt; Users { get; set; }
          public virtual IList&lt;Role&gt; Roles { get; set; }
  
          public Role()
          {
              Users = new List&lt;User&gt;();
          }
      }
  </code></pre>
  
  <p>UserMap Class</p>
  
  <pre><code>public class UserMap : ClassMap&lt;User&gt;
      {
          public UserMap()
          {
              Table("tblUsers");
  
              Id(user =&gt; user.UserID).GeneratedBy.Guid();
              Map(user =&gt; user.UserName).Not.Nullable();
              Map(user =&gt; user.Password).Not.Nullable();
              Map(user =&gt; user.FullName).Not.Nullable();
              Map(user =&gt; user.Email).Not.Nullable();
              //Map(user =&gt; user.LastLogin).Nullable();
              Map(user =&gt; user.IsActive).Not.Nullable();
              Map(user =&gt; user.CreationDate).Not.Nullable();
  
  
              HasManyToMany&lt;Role&gt;(x =&gt; x.Roles).Table("tblUserInRoles")
                                                  .ParentKeyColumn("UserID")
                                                  .ChildKeyColumn("RoleID")
                                                  .Cascade.All()
                                                  //.AsSet()
                                                  //.Inverse()
                                                  .Not.LazyLoad();
  
  
          }
      }
  </code></pre>
  
  <p>RoleMap Class</p>
  
  <pre><code>public class RoleMap : ClassMap&lt;Role&gt;
      {
          public RoleMap()
          {
              Table("tblRoles");
              Id(role =&gt; role.RoleID).GeneratedBy.Identity();
              Map(role =&gt; role.RoleName).Not.Nullable();
              Map(role =&gt; role.IsActive).Not.Nullable();
              Map(role =&gt; role.Description).Not.Nullable();
  
              HasManyToMany&lt;User&gt;(x =&gt; x.Users)
                  .Table("tblUserInRoles")
                  .ParentKeyColumn("RoleID")
                  .ChildKeyColumn("UserID")
                  .Cascade.All()
                  .Inverse()
                  .Not.LazyLoad();
          }
      }
  </code></pre>
  
  <p>My questions are:</p>
  
  <ul>
  <li>I want to delete all roles of particular user? [Answered by danyolgiax]   </li>
  <li>Get roles of user </li>
  </ul>
  
  <p>Can Any one guide me..</p>