Could not determine member from.. exception

419 views
Skip to first unread message

Filip Kinsky

unread,
Mar 12, 2009, 6:11:16 AM3/12/09
to NhLambdaExtensionsUsers
Hello, I'm just evaluating NHLambdaExtensions, but my first attempt
resulted in strange exception I'm not able to solve at the moment. I
have simple User class like this:

public class User: PersistentObject
{
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string PasswordHash { get; set; }

public IList<Role> Roles{ get; private set;}
...
}

and repository which makes use of NHLambda:

public class UserRepository: RepositoryBase<User>, IUserRepository
{
public User FindByUserNameAndPasswordHash(string userName, string
pwdHash)
{
return FindOne(DetachedCriteria.For<User>()
.Add<User>(u => u.UserName == userName &&
u.PasswordHash == pwdHash));
}
}

I get following exception when calling this repository method from my
application:

Could not determine member from (u.UserName = value
(App.Service.Persistence.Repositories.Core.Security.UserRepository
+<>c__DisplayClass0).usr)

Am I doing something wrong? I was trying to look in NHLAmbda source,
but didn't find anythink yet..

the stack trace for exception:

[Exception: Could not determine member from (u.UserName = value
(PromoSystemX.Service.Persistence.Repositories.Core.Security.UserRepository
+<>c__DisplayClass0).usr)]
NHibernate.LambdaExtensions.ExpressionProcessor.FindMemberExpression
(Expression expression) +463

NHibernate.LambdaExtensions.ExpressionProcessor.ProcessSimpleExpression
(BinaryExpression be) +18

NHibernate.LambdaExtensions.ExpressionProcessor.ProcessBinaryExpression
(BinaryExpression expression) +37

NHibernate.LambdaExtensions.ExpressionProcessor.ProcessLambdaExpression
(LambdaExpression expression) +68
NHibernate.LambdaExtensions.DetachedCriteriaExtensions.Add
(DetachedCriteria criteria, Expression`1 expression) +24

PromoSystemX.Service.Persistence.Repositories.Core.Security.UserRepository.FindByUserNameAndPasswordHash
(String userName, String pwdHash) in C:\Develop\PromoSystemX\source
\PromoSystemX.Service\Persistence\Repositories\Core\Security
\UserRepository.cs:18

PromoSystemX.Service.Core.Security.AuthenticationService.AuthenticateUser
(String userName, String passwordHash) in C:\Develop\PromoSystemX
\source\PromoSystemX.Service\Core\Security\AuthenticationService.cs:33
PromoSystemX.Web.Controllers.AccountMembershipService.ValidateUser
(String userName, String password) in C:\Develop\PromoSystemX\source
\PromoSystemX.Web\Controllers\AccountMembershipService.cs:36
PromoSystemX.Web.Controllers.AccountController.ValidateLogOn(String
userName, String password) in C:\Develop\PromoSystemX\source
\PromoSystemX.Web\Controllers\AccountController.cs:208
PromoSystemX.Web.Controllers.AccountController.LogOn(String
userName, String password, Boolean rememberMe, String returnUrl) in C:
\Develop\PromoSystemX\source\PromoSystemX.Web\Controllers
\AccountController.cs:59
lambda_method(ExecutionScope , ControllerBase , Object[] ) +245
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase
controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary`2 parameters) +178
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod
(ControllerContext controllerContext, ActionDescriptor
actionDescriptor, IDictionary`2 parameters) +24

System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7
() +52
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter
(IActionFilter filter, ActionExecutingContext preContext, Func`1
continuation) +254

System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9
() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters
(ControllerContext controllerContext, IList`1 filters,
ActionDescriptor actionDescriptor, IDictionary`2 parameters) +192

PromoSystemX.Web.Util.AppControllerActionInvoker.InvokeActionMethodWithFilters
(ControllerContext controllerContext, IList`1 filters,
ActionDescriptor actionDescriptor, IDictionary`2 parameters) in C:
\Develop\PromoSystemX\source\PromoSystemX.Web\Util
\AppControllerActionInvoker.cs:38
System.Web.Mvc.ControllerActionInvoker.InvokeAction
(ControllerContext controllerContext, String actionName) +399
System.Web.Mvc.Controller.ExecuteCore() +126
System.Web.Mvc.ControllerBase.Execute(RequestContext
requestContext) +27
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute
(RequestContext requestContext) +7
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
httpContext) +151
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)
+57
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest
(HttpContext httpContext) +7

System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +75

Filip Kinsky

unread,
Mar 12, 2009, 6:31:03 AM3/12/09
to NhLambdaExtensionsUsers
I just debugged into NHLambda source code and the expression type is
System.Linq.Expressions.BinaryExpression if it helps to find out
what's wrong...

Richard Brown (GMail)

unread,
Mar 12, 2009, 10:16:02 AM3/12/09
to NhLambdaExtensionsUsers
Hi Filip,

The NhLambdaExtensions allow a typesafe interface to ICriteria, but do not
provide a complete LINQ provider.

The following should work ok:

return FindOne(DetachedCriteria.For<User>()
.Add<User>(u => u.UserName == userName)
.Add<User>(u => u.PasswordHash == pwdHash);

Regards,
Richard

--------------------------------------------------
From: "Filip Kinsky" <fi...@filovo.net>
Sent: Thursday, March 12, 2009 10:31 AM
To: "NhLambdaExtensionsUsers" <nhlambdaext...@googlegroups.com>
Subject: Re: Could not determine member from.. exception

Filip Kinsky

unread,
Mar 12, 2009, 12:54:40 PM3/12/09
to NhLambdaExtensionsUsers
Thanks a lot - I understand it now...

On 12 Bře, 15:16, "Richard Brown \(GMail\)" <fluke...@googlemail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages