“Lambda Parameter not in scope” exception using SimpleRepository's Single method

走远了吗. 提交于 2019-12-13 03:45:06

问题


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:


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



来源:https://stackoverflow.com/questions/1186320/lambda-parameter-not-in-scope-exception-using-simplerepositorys-single-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!