存储性能不良:原因不明

2023-12-14

是什么原因造成的错误的存储属性:成员“resetQueryStatus.Employee.employeeId”上的“_employeeId”。例外?

例外似乎出现在我的连接点处:

 [Database]
public class FireEvacuation : DataContext
{
    public Table<Employee> EmployeeDetails;
    public Table<EmpDepartment> Department;
    public Table<EmpStatus> Status;

    **public FireEvacuation(string connection) : base(connection) { }** //exception thrown here
}

员工详情实体类

//create class and map it to FireEvacuation table
[Table(Name = "EmployeeDetails")]
public class Employee
{
    public string _employeeId;
    //designate employeeId property on the entity class as representing column in the database table
    //employeeId is designated to be a primary key column in the database
    //employeeName is designated as private storage ==> allows LINQ to SQL to directly store and retrieve values
    [Column(IsPrimaryKey = true, Storage = "_employeeId", DbType = "int(System.Int32) NOT NULL")]
    public string employeeId
    {
        get
        {
            return this._employeeId;
        }
        set
        {
            this._employeeId = value;
        }

    }

    public string _employeeName;
    //designate employeeName property on the entity class as representing column in the database table
    //employeeName is designated as private storage ==> allows LINQ to SQL to directly store and retrieve values
    [Column(Storage = "_employeeName", DbType = "nvarchar(50) NULL")]
    public string employeeName
    {
        get
        {
            return this._employeeName;
        }
        set
        {
            this._employeeName = value;
        }

    }

    public string _departmentId;
    [Column(Storage = "_departmentId", DbType = "int(System.Int32) NULL")]
    public string departmentId
    {
        get
        {
            return this._departmentId;
        }
        set
        {
            this._departmentId = value;
        }
    }

    public string _statusId;
    [Column(IsPrimaryKey = true, Storage = "_statusId", DbType = "int(System.Int32) NULL")]
    public string statusId
    {
        get
        {
            return this._statusId;
        }
        set
        {
            this._statusId = value;
        }

    }

}

部门实体类

 [Table(Name = "Department")]
public class EmpDepartment
{
    public string _departmentId;
    [Column(IsPrimaryKey = true, Storage = "_departmentId", DbType = "int(System.Int32) NOT NULL")]
    public string departmentId
    {
        get
        {
            return this._departmentId;
        }
        set
        {
            this._departmentId = value;
        }

    }

    public string _departmentName;
    [Column(Storage = "_departmentName", DbType = "nvarchar(50) NOT NULL")]
    public string departmentName
    {
        get
        {
            return this._departmentName;
        }
        set
        {
            this._departmentName = value;
        }

    }
}

状态实体类

[Table(Name = "Status")]
public class EmpStatus
{
    public string _statusId;
    [Column(IsPrimaryKey = true, Storage = "_statusId", DbType = "int(System.Int32) NOT NULL")]
    public string statusId
    {
        get
        {
            return this._statusId;
        }
        set
        {
            this._statusId = value;
        }

    }

    public string _statusDescription;
    [Column(Storage = "_statusDescription", DbType = "nvarchar(50) NOT NULL")]
    public string statusName
    {
        get
        {
            return this._statusDescription;
        }
        set
        {
            this._statusDescription = value;
        }

    }
}

这是我的查询代码,用于从上述实体获取值:

static void Main(string[] args)
    {

        // Use a connection string.
        FireEvacuation db = new FireEvacuation
            (@"C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\runSqlLinq\FireEvacuation.mdf");

        do
        {

            // Attach the log to show generated SQL.
            db.Log = Console.Out;

            string name = "John";

            //Query for account status
                var query = from emp in db.EmployeeDetails
                            join stat in db.Status on emp._statusId equals stat._statusId
                            join dep in db.Department on emp._departmentId equals dep._departmentId
                            where emp._employeeName == name
                            select new { emp, stat, dep };

                foreach (var q in query)
                {
                    Console.WriteLine("Department Name = {0} Employee Name = {1} Status Name = {2}", q.dep._departmentName, q.emp._employeeName, q.stat._statusDescription);
                }

        }
        while (Console.ReadKey(true).Key != ConsoleKey.Escape);
        //Thread.Sleep(60000);
    }//end of main

请帮忙谢谢!


发现我的错误:

存储字段/属性不能是公共的。

当它成为私有的那一刻,问题就消失了。希望这可以帮助其他人下次解决同样的问题。 :)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

存储性能不良:原因不明 的相关文章

随机推荐

  • Windows 不会从所有接口接收多播 IPv6 数据包

    我正在尝试使用此 python 2 7 代码在 Windows 上接收 IPv6 多播数据包 发送到 ff02 1 地址 import socket import win inet pton import struct socket IPP
  • 在java中添加一个简单的按钮,但java不允许我这样做

    好吧 从我的角度来看 我的代码相当不错 足以获得及格分数 但我在添加简单的刷新 随机播放按钮时遇到了麻烦 不使用 JOptionPane 的帮助 Eclipse 似乎没有意识到我创建了一个按钮 这对我来说根本没有意义 因为它告诉我一些关于节
  • python 中的猴子修补:什么时候我们需要它?

    在 Python 中 术语monkey patch仅指在运行时动态修改类或模块 作为初学者 我很难在 python 上下文中理解这个术语 有人能用一个现实世界的例子向我解释一下我们到底是怎么做的吗 类的动态修改 运行时动态修改模块 我坚持用
  • 查找下一个最接近的日期

    我有一些日期当前存储为字符串列表 例如 List
  • 将资源绑定到自定义控件属性

    我正在创建一个自定义按钮 通常显示稍微褪色的文本 并在MouseOver or MouseDown 我在中定义了两个资源Generic xaml我的控件来表示这些文本颜色的画笔
  • edu.stanford.nlp.io.RuntimeIOException:无法连接到服务器

    我正在尝试使用 CoreNLP 服务器注释多个句子 但是 如果我尝试这样做too many我得到的句子 Exception in thread Thread 48 edu stanford nlp io RuntimeIOException
  • Android 片段无法正确替换

    我正在尝试使用片段构建 3 0 的应用程序 应用程序的左侧有一个静态片段 右侧有一个动态片段 我的动态部分中的每个片段都有一个标题 每当我去替换初始片段时 第一个片段的标题仍然显示在第一个片段的标题上方 连续的替换替换了下部 但仍然显示初始
  • 并发更新期间的 Hibernate StaleObjectStateException

    我在 Java J2EE Web 应用程序中使用 Hibernate 3 5 2 和 Spring Core 3 0 1 当不同的用户同时更新同一记录时 我收到 StaleObjectStateExcpetion 事务由 javax per
  • 带有 2 行文本的 Windows Phone 8.1 AppBarButton 图标

    我想知道如何使 AppBarButton 图标具有 2 行文本 我想让它像 Windows 日历中一样 AppBarButton 不在其图标中显示文本或任意 Xaml 它必须是来自字体 位图或路径的符号 对于这样的日历显示 最好使用位图 由
  • 如何在 Isabelle 中定义偏函数?

    我尝试用以下方法定义偏函数partial function关键词 它不起作用 这是最能表达直觉的 partial function tailrec oddity nat gt nat where oddity Zero Zero oddit
  • 如何通过 Google Apps 日历脚本向访客发送邀请

    我正在尝试通过 Google Apps 脚本将访客添加到日历活动 并在我的脚本添加访客后立即发送邀请 但我找不到向客人发送电子邮件邀请的方法 var events calendar getEvents start date end date
  • firebase实时数据库安全规则允许特定用户

    我当前的 Firebase 实时安全规则如下 rules users read true indexOn email user id read true write auth null user id auth uid 它们翻译为只有经过身
  • ASIHTTPRequest 支持的 RestKit 对象映射

    我们必须支持一些使用 ASIHTTPRequest 运行的旧代码 但我们希望 RestKit 提供对象映射和核心数据支持 有谁知道有什么方法可以将这两者 粘合 在一起吗 我想象使用 ASIHTTPRequest 来处理请求 然后有人手动将有
  • 双精度重载运算符=

    是否可以重载 double 类型的 运算符 我有以下内容 double operator double a Length b return a b getInches 12 b getFeet 3 2808 0 9144 它抛出以下错误 d
  • 在视图上创建遮罩效果

    我想在 UIView 上创建遮罩效果以完成以下任务 我将在屏幕中显示一个密封的盒子 用户将能够触摸 刮擦 屏幕以显示该图像 UIView 后面的内容 类似于那些彩票 你应该刮掉结果顶部的一些封面材料 如果有人能指出我正确的方向那就太棒了 我
  • 如何更改 UITableView 的高度以适应其动态内容?

    我有一个 UITableView 其中包含一个单元格 该单元格又 包含一个 TTTextEditor Three20 控件 它的所有意图和目的都是 UITextView 我使用 TTTextEditor 以便用户可以输入动态数量的文本 并且
  • xcode 中的调试符号是什么

    什么是调试符号 用法是什么 能够将带有调试符号的应用程序提交到应用程序商店吗 请帮忙 提前致谢 dSym 在您归档项目时生成 您无需为此做任何事情 它允许你符号化你的崩溃日志 否则它只是毫无意义的内存地址 它是构建代码和源代码之间的链接
  • Android 弹出菜单填充父级

    我尝试设置弹出菜单来填充网格上的孔项目 目前它看起来像所附的第一张图片 下一张是我想要的效果 My code private void showPopupMenu View view inflate menu ContextThemeWra
  • 使用 Laravel 5.3 的 Amazon SES 403 Forbidden SignatureDoesNotMatch

    我正在使用 Laravel 5 3 EC2 和 SES 发送电子邮件 配置 邮件 php driver gt env MAIL DRIVER smtp host gt env MAIL HOST smtp mailgun org port
  • 存储性能不良:原因不明

    是什么原因造成的错误的存储属性 成员 resetQueryStatus Employee employeeId 上的 employeeId 例外 例外似乎出现在我的连接点处 Database public class FireEvacuat