Thanks, I don't know how I missed that. But I've been toying with it and I
can't get it quite right. It keeps returning null. Am I right to use
QueryForObject? This is what I have but I don't know what I'm doing wrong:

SqlMap.config:
    <alias>
      <typeAlias alias="MembershipUser"
type="System.Web.Security.MembershipUser, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <typeAlias alias="MembershipUserCollection"
type="System.Web.Security.MembershipUserCollection, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </alias>

    <resultMaps>
      <resultMap id="MembershipUserResult" class="MembershipUser">
        <constructor>
          <argument argumentName="providerName" column="ProviderName"
type="string" dbType="VarChar" />
          <argument argumentName="name" column="UserName" type="string"
dbType="VarChar" />
          <argument argumentName="providerUserKey" column="UserID"
type="object" dbType="VarChar" />
          <argument argumentName="email" column="Email" type="string"
dbType="VarChar" />
          <argument argumentName="passwordQuestion"
column="PasswordQuestion" type="string" dbType="VarChar" />
          <argument argumentName="comment" column="Comment" type="string"
dbType="VarChar" />
          <argument argumentName="isApproved" column="IsApproved"
type="bool" dbType="Boolean" />
          <argument argumentName="isLockedOut" column="IsLockedOut"
type="bool" dbType="Boolean" />
          <argument argumentName="creationDate" column="DateCreated"
type="dateTime" dbType="Date" />
          <argument argumentName="lastLoginDate" column="LastLoginDate"
type="dateTime" dbType="Date" />
          <argument argumentName="lastActivityDate" column="DateModified"
type="dateTime" dbType="Date" />
          <argument argumentName="lastPasswordChangedDate"
column="LastPasswordChangedDate" type="dateTime" dbType="Date" />
          <argument argumentName="lastLockoutDate" column="LastLockoutDate"
type="dateTime" dbType="Date" />
        </constructor>
      </resultMap>
    </resultMaps>

      <select id="select-all-users" listClass="MembershipUserCollection"
resultMap="MembershipUserResult">
        SELECT *
        FROM Memberships
      </select>

.NET implementation:
       public MembershipUserCollection GetAllUsers()
        {
            try
            {
                return DataPortal.Users.QueryForObject("select-all-users",
null) 
                    as MembershipUserCollection;
            }
            catch
            {
                throw;
            }
        }

All my other sql methods work and am able to get a single MembershipUser (I
have to use the resultsMap to feed the constructor because Microsoft doesn't
allow any other way to populate an existing MembershipUser, many read-only
properties). But when I use the listClass above, it compiles fine but it
returns null. I've also tried <statement> instead of <select> and the same
problem happens. What am I missing??


dCyphr wrote:
> 
> I'm trying to implement the GetAllUser method in the Membership Provider
> and I have to return a MembershipUserCollection populated with
> MembershipUser objects. Is this possible? I'm pretty much looking for
> (which doesn't exist of course):
> 
> public T QueryForCollection<T, U>
> 
> where T would be MembershipUserCollection and U would be MembershipUser.
> Is there any way to achieve something like this? My only option I can
> think of is loading the IList with MembershipUsers, then loop thru the
> IList and populate a MembershipUserCollection one by one in my code, but
> that's really redundant. Any ideas?
> 

-- 
View this message in context: 
http://www.nabble.com/How-can-I-populate-MembershipUserCollection-instead-of-IList--tp16184430p16275132.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.

Reply via email to