“Lambda 参数不在范围内"使用 SimpleRepository 的 Single 方法的异常 [英] "Lambda Parameter not in scope" exception using SimpleRepository's Single method

查看:18
本文介绍了“Lambda 参数不在范围内"使用 SimpleRepository 的 Single 方法的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 SimpleRepository 执行基于非 ID 属性的提取.这是我正在使用的 Customer 类:

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;
        }
    }

我正在使用打开迁移的 SimpleRepository.抛出Lambda 参数不在范围内"的代码如下:

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;
        }
    }

我不确定这会在 LINQ 表达式编译的哪一点引发,但我正在一个空数据库上运行此示例.模式生成足以创建表结构,但无法计算表达式.

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?

谢谢!

推荐答案

我收到了这方面的报告 - 你能将此(和你的代码)添加为问题吗?

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

这篇关于“Lambda 参数不在范围内"使用 SimpleRepository 的 Single 方法的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆