无法将方法组“List”转换为非委托类型

时间:2013-07-30 13:13:42

标签: c# nhibernate

public object Execute(UpdateUserStatusMessage message)
{

    IList<UserPreferredAccount> CustomerList = null;

    var query = CPSession.CreateSQLQuery("exec CP.CP_USR_CNTCT_CSTMR_SELECT :userId ");
    query.SetInt32("userId", message.CpUserCntctId);
    query.SetResultTransformer(Transformers.AliasToBean(typeof(UserPreferredAccount)));

    var model = new UpdateUserStatusModel
      {
        UserId = message.CpUserCntctId,
        UserPreferredAccounts =  query.List<UserPreferredAccount>
      };

  return model;
}

这是UpdateUserStatusModel:

    public class UpdateUserStatusModel{
        public int UserId {set; get;}
        public IList<UserPreferredAccount> UserPreferredAccounts{set; get;}
}

它给了我标题中描述的错误,我认为它们都是相同的类型。

1 个答案:

答案 0 :(得分:2)

你需要括号而不是分号:

UserPreferredAccounts =  query.List<UserPreferredAccount>()