Guest User

Untitled

a guest
Jan 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public class Employee
  2. {
  3. public long Id { get; set; }
  4. public string Forename { get; set; }
  5. public string Surname {get; set; }
  6. public string FullName { get { return Forename + " " + Surname; }}
  7. }
  8.  
  9. <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
  10. namespace="Domain.Entities"
  11. assembly="Domain">
  12. <class name="Employee" table="`Employee`">
  13. <id name="Id" column="Id" type="long">
  14. <generator class="identity"/>
  15. </id>
  16. <property name="Forename"/>
  17. <property name="Surname"/>
  18. </class>
  19. </hibernate-mapping>
  20.  
  21. public Employee GetByFullName(string fullName)
  22. {
  23. return _session
  24. .CreateCriteria<Employee>
  25. .Add(Restrictions.Eq("FullName", fullName))
  26. .List<Employee>();
  27. }
  28.  
  29. <property name="Fullname" formula="Forename + ' ' + Surname"/>
  30.  
  31. public virtual string Fullname {
  32. get { return Forename + " " + Surname; }
  33. set { } // do nothing
  34. }
Add Comment
Please, Sign In to add comment