简体   繁体   English

Linq2Sql没有显示在C#类中

[英]Linq2Sql not showing in C# Class

I have a Asp.NET C# Project where i have created a Linq2SQL Model. 我有一个Asp.NET C#项目,在其中创建了Linq2SQL模型。

In a file i have to use it and somewhy its not showing up in intelicense form visual studio. 在文件中,我必须使用它,并且为什么它不能以可视形式的可视工作室出现在智能手机中。

when i try to use InformitoDatabaseDataContext db = new InformitoDatabaseDataContext(); 当我尝试使用InformitoDatabaseDataContext db = new InformitoDatabaseDataContext(); it doesnt recognize InformitoDatabaseDataContext. 它无法识别InformitoDatabaseDataContext。

The name of the .dbml file is InformitoDatabase.dbml .dbml文件的名称是InformitoDatabase.dbml

Solution Explorer 解决方案资源管理器

Image of Project (Update) 项目图片(更新)

What can i do to "connect" the dbml file to my class? 如何将dbml文件“连接”到我的班级?

I suspect the problem is that you're using ...DataContent when normally it would be ...DataContext , with an x instead of an n . 怀疑问题在于您通常在使用...DataContent时使用...DataContext ,而使用x而不是n

(Your screenshot shows the failure - with a different name from the one in the question - but not where the context itself is declared, which leaves us guessing somewhat... but as UserChosenPrefixDataContext is the default, it's highly likely that's what's wrong.) (您的屏幕截图显示了失败-与问题中的名称不同的名称-但未声明上下文本身的位置,这让我们有所猜测...但是由于UserChosenPrefixDataContext是默认值,因此很可能是错误的)。

EDIT: You've now changed your post to talk about SchoolDatabaseDataContext , but in the screenshot highlighting the failure, you're referring to InformitoDatabaseDataContent . 编辑:您现在已更改帖子以谈论SchoolDatabaseDataContext ,但在突出显示失败的屏幕截图中,您指的是InformitoDatabaseDataContent

我很确定默认值为DataContext,而不是DataContent。

I find the solution, the problem is that you are missing InformitoDatabaseDataContext.designer.cs class Check you are missing it or not. 我找到了解决方案,问题是您缺少InformitoDatabaseDataContext.designer.cs类检查您是否缺少它。

I just add a dbml file to aap code folder, it consist of three files, 我只是将dbml文件添加到aap代码文件夹中,该文件包含三个文件,

  1. informitodatabase.dbml notifyitodatabase.dbml
  2. informitodatabase.dbml.layout notifyitodatabase.dbml.layout
  3. informitodatabase.designer.cs notifyitodatabase.designer.cs

when I add a new file in the root directoy it misses the designer file When I created the object of both the files, the file which is present in App_Code folder is accessible while other one is not accessible. 当我在目录的根目录中添加新文件时,它会丢失设计器文件。当我创建两个文件的对象时,可以访问App_Code文件夹中存在的文件,而不能访问另一个文件。

See the below image file, I added two files in App_Code folder and two in the Root Directory. 参见下面的图像文件,我在App_Code文件夹中添加了两个文件,在根目录中添加了两个文件。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM