Note that there are some explanatory texts on larger screens.

plurals
  1. POnull values in NHibernate returning list
    primarykey
    data
    text
    <p>I'm trying to understand the following behaviour of NHibernate and can't.</p> <pre><code>session.CreateCriteria&lt;Param&gt;() .Add(Restrictions.Eq("GroupId", groupId)) .Add(Restrictions.Eq("ParamId", paramId)) .List&lt;Param&gt;() </code></pre> <p>This construction should return collection with 1 database row(object). But returns list with single null element. Could you suggest why?</p> <p>P.S. Param class mapping has a composite key.</p> <pre><code>public class Param { public Param() { } public Param(string groupId, string paramId, string paramName) : this() { GroupId = groupId; ParamId = paramId; ParamName = paramName; } public virtual string GroupId { get; protected set; } public virtual string ParamId { get; protected set; } public virtual string ParamName { get; protected set; } public virtual string Value { get; set; } public override bool Equals(object obj){...} public override int GetHashCode(){...} } public class ParamMap : ClassMap&lt;Param&gt; { public ParamMap() { Table("Params"); CompositeId() .KeyProperty(x =&gt; x.GroupId) .KeyProperty(x =&gt; x.ParamId) .KeyProperty(x =&gt; x.ParamName, "ParamName"); Map(x =&gt; x.Value, "ParamValue"); } } </code></pre> <p>This query is copied from database log. NHibernate executes it.</p> <pre><code>SELECT THIS_.GROUPID AS GROUPID19_0_, THIS_.PARAMID AS PARAMID19_0_, THIS_.PARAMNAME AS PARAMNAME19_0_, THIS_.PARAMVALUE AS PARAMVALUE19_0_ FROM PARAMS THIS_ WHERE THIS_.GROUPID = :1 AND THIS_.PARAMID = :2 \ WorkHour,TotalHours, / </code></pre> <p>Returns 1 row:</p> <pre><code>GroupId = "WorkHour" ParamId = "TotalHours" ParamName = (empty) ParamValue = YES </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload