views:

245

answers:

2

Hi

I've built an authentication service in RIA that inherits from DomainService and IAuthenticate.

The problem is following:

When LoginOperation fails (loginOperation.LoginSuccess is false) due to wrong credentials, everything is ok and it is reported to the user.

However, when login succeeds, I get throw a really weird exception:

{System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'Login'. Value cannot be null.

Parameter name: validationErrors ---> System.ArgumentNullException: Value cannot be null. Parameter name: validationErrors at System.ServiceModel.DomainServices.Client.QueryCompletedResult..ctor(IEnumerable1 entities, IEnumerable1 includedEntities, Int32 totalCount, IEnumerable`1 validationErrors)


I don't really understand this. What is IEnumerable validationErrors, where does it appear and why does it have to be != null ? This started happening after I ported my authentication services from Nhibernate to Entity Framework. I've even tried googling this exception and apparently I'm the only one with this problem so far.

Any help would be greatly appreciated.

A: 

It seems that RIA doesn't support linq expressions in properties. Getter in IEnumerable Roles was the problem. You have to fill it manually; you can't write things like return (from a in User.UserRoles select a.Description).AsEnumerable();, it won't work.

VexXtreme
A: 

Hello VexXtreme,

I had the same problem, thank you for your help !!!

However, it's possible when you do a ToList() like this:

[DataMember]
public IEnumerable<string> Roles
{
    get
    {
        return ApplicationRoles.Select(r => r.Name).ToList();
    }
    set
    {
        // TODO
    }
}
Stef