views:

294

answers:

1

Hello,

I'm attempting to use the SimpleRepository to perform a fetch based on a non-ID property. Here's the Customer class I'm using:

    [Serializable]
    public class Customer : IEntity<Guid>
    {
        public Guid ProviderUserKey { get; set; }

        public Guid ID
        {
            get; set;
        }
    }

I'm using SimpleRepository with migrations turned on. The code that throws the "Lambda Parameter not in scope" is below:

    public class CustomerRepository : 
        ICustomerRepository
    {
        private readonly IRepository _impl;

        public CustomerRepository(string connectionStringName)
        {
            _impl = new SimpleRepository(connectionStringName,
                                         SimpleRepositoryOptions.RunMigrations);
        }

        public Customer GetCustomer(string userName)
        {
            var user = Membership.GetUser(userName);

            // Code to guard against a missing user would go here

            // This line throws the exception
            var customer = _impl.Single<Customer>(c => c.ProviderUserKey.Equals(user.ProviderUserKey));

            // Code to create a new customer based on the
            // ASP.NET Membership user would go here

            return customer;
        }
    }

I'm not sure at what point in the LINQ expression compilation this throws, but I am running this example on an empty database. The schema generations gets far enough to create the table structure, but can't evaluate the expression.

Does anyone know what I might be doing wrong?

Thanks!

+1  A: 

I've had reports of this - can you add this (and your code) as an issue please?

Rob Conery
Hi, I'm getting this error too, but I'm using Find method.
ryudice
Hi Rob I'm using SubSonic 3.0.4 and trying to do this:`x=> x.FirstName.ToUpper().StartsWith(name)` it throws exception when constructing `Constraint` because constraintfragment is null. works without `ToUpper`
TheVillageIdiot