-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem databinding to results containing proxy
PostPosted: Fri Jul 11, 2008 4:43 pm 
Newbie

Joined: Fri Jul 11, 2008 3:24 pm
Posts: 1
I am having a problem when databinding a gridview to an IList of results from nHibernate. When the first item in the list is not a proxy object, it works fine. But if it is a proxy object, I get this error:
Code:
  TargetInvocationException: Property accessor 'Username' on object 'ThisProject.Domain.Model.Implementations.User' threw the following exception:'Object does not match target type.'


My code is pretty simple:
Code:
  IList<User> users = _userRepository.GetUsersForSite(currentSite.Id);
  gvUsers.DataSource = users;
  gvUsers.DataBind();


My mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ThisProject.Domain.Model.Implementations" assembly="ThisProject.Domain" default-access="field.camelcase-underscore"  >
  <class name="User" table="Users" dynamic-update="true">
    <id name="Id" column="user_id" type="Int32">
      <generator class="identity" />
    </id>
    <property name="Username" type="String" insert="false" update="false"/>
    <property name="FirstName" column="name_first" insert="false" update="false" />
    <property name="LastName" column="name_last" insert="false" update="false"  />
    <property name="MiddleName" column="name_middle" insert="false" update="false" />
    <property name="Suffix" column="name_suffix" insert="false" update="false" />
    <property name="PhoneNumber" column="phone" insert="false" update="false" />
    <property name="FaxNumber" column="fax" insert="false" update="false" />
    <property name="EmailAddress" column="email" insert="false" update="false" />
    <property name="JobTitle" column="job_title" insert="false" update="false" />
    <property name="IsActive" column="is_active" insert="false" update="false" />
    <property name="DealerID" column="dlrcode" insert="false" update="false" />
    <bag name="AccessibleSites" table="users_sites" cascade="none" lazy="true">
      <key column="user_id" />
      <many-to-many column="site_id" class="ThisProject.Domain.Model.Implementations.Site, ThisProject.Domain"/>
    </bag>
  </class>
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.