C# 在以下情况下获取具有键(PK)的实体不会往返:使用视图时
我已经浏览了关于这个主题的其他问题,其中大部分提到编辑edmx文件。我在Visual Studio Express 2015中工作,找不到任何edmx文件,也无法确定错误引用的内容/位置。当我转到一个甚至没有绑定到相关视图的页面时,会生成错误。 最初我使用带有case语句的视图,然后改为使用union语句的视图,然后接受子查询并将其作为单独的视图。我不知道为什么会发生错误。有问题的列是四个图像列。更新:更改了基础数据表并更改了下面的所有表单以使用新表,只需要立即打开视图即可获取所有对象。表之间定义了外键关系。新视图如下: 视图1:C# 在以下情况下获取具有键(PK)的实体不会往返:使用视图时,c#,sql,asp.net,C#,Sql,Asp.net,我已经浏览了关于这个主题的其他问题,其中大部分提到编辑edmx文件。我在Visual Studio Express 2015中工作,找不到任何edmx文件,也无法确定错误引用的内容/位置。当我转到一个甚至没有绑定到相关视图的页面时,会生成错误。 最初我使用带有case语句的视图,然后改为使用union语句的视图,然后接受子查询并将其作为单独的视图。我不知道为什么会发生错误。有问题的列是四个图像列。更新:更改了基础数据表并更改了下面的所有表单以使用新表,只需要立即打开视图即可获取所有对象。表之间定
CREATE VIEW [dbo].[V_Questions]
AS SELECT Questions.QuestionID Id, Author, ImageFile, Image1Content, Image1Name,
ImageFile2, Image2Content, Image2Name, ImageFile3, Image3Content, Image3Name,
ImageFile4, Image4Content, Image4Name, SubmitDate, Stem, RespA, RespB, RespC, RespD, RespE, Answer, Critique, KeyObjective, [References], PracticeArea1,PracticeArea2, PracticeArea3, PracticeArea4, IsCloneOf
FROM [Questions]
Left join Images on Questions.ImageID = Images.ImageID
错误消息(基本不变,行号已更改,但四个图像文件仍存在问题):
“/”应用程序中出现服务器错误
(74,10):错误3004:映射从第行开始的片段时出现问题74:没有为属性V_Question.ImageFile指定映射, 中的V_Question.ImageFile2、V_Question.ImageFile3、V_Question.ImageFile4 设置V_问题。具有密钥(PK)的实体在以下情况下不会往返: 实体类型为[cs1.Models.V_Question] 当第74行开始视图的定义时,我想我已经找到了被投诉的文件(V_Question.designer.cs)。 这是从第74行开始到/包括第一个imagefile记录的文件,我如何修复它
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.V_Questions")]
public partial class V_Question
{
private int _Id;
private string _Author;
private System.Data.Linq.Binary _ImageFile;
private string _Image1Content;
private string _Image1Name;
private System.Data.Linq.Binary _ImageFile2;
private string _Image2Content;
private string _Image2Name;
private System.Data.Linq.Binary _ImageFile3;
private string _Image3Content;
private string _Image3Name;
private System.Data.Linq.Binary _ImageFile4;
private string _Image4Content;
private string _Image4Name;
private string _SubmitDate;
private string _Stem;
private string _RespA;
private string _RespB;
private string _RespC;
private string _RespD;
private string _RespE;
private string _Answer;
private string _Critique;
private string _KeyObjective;
private string _References;
private string _PracticeArea1;
private string _PracticeArea2;
private string _PracticeArea3;
private string _PracticeArea4;
private int _IsCloneOf;
public V_Question()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Id", DbType="Int NOT NULL")]
public int Id
{
get
{
return this._Id;
}
set
{
if ((this._Id != value))
{
this._Id = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Author", DbType="NVarChar(100) NOT NULL", CanBeNull=false)]
public string Author
{
get
{
return this._Author;
}
set
{
if ((this._Author != value))
{
this._Author = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ImageFile", DbType="VarBinary(MAX)", UpdateCheck=UpdateCheck.Never)]
public System.Data.Linq.Binary ImageFile
{
get
{
return this._ImageFile;
}
set
{
if ((this._ImageFile != value))
{
this._ImageFile = value;
}
}
}