实体框架6与SQL Server表稀疏列和Xml列集为All_sparse_columns [英] Entity Framework 6 with SQL Server table Sparse column and Xml Column Sets For All_sparse_columns

查看:61
本文介绍了实体框架6与SQL Server表稀疏列和Xml列集为All_sparse_columns的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我,在EF 6中,DbContext是否在将数据插入表的所有稀疏列后自动将数据插入到表的Xml列中。如果我只在所有SPARSE列中在SQL Server中执行INSERT语句,结果是它还将
数据自动插入Xml列。我怎样才能在EF 6的DbContext相同functionalty


表结构:


表名称:版税


列:


         Id int主键


         SparseCol1稀疏varchar(50)null,


         SparseCol2稀疏varchar(50)null,


         XmlCol XML列设定为all_sparse_columns


下面是coode:


 类节目

     {

        static void Main(string [] args)

        {

       

         &NBSP ; 使用(var db = new NewContext())

            {

                    &NBSP ;      

解决方案

您好,


<强> >>但我希望&NBSP;&NBSP; XmlCol应该填充&NBSP;


如何您期望的XmlCol填充?以及填充到XMLCol中的内容?由于稀疏列在数据库中没有默认值,因此您应该添加XMLCol 按代码。您可以在  entities
的属性中执行此操作。





 

public string xmlcol
{
get {return xmlcol; }
set {xmlcol =" XML" ;; }

}

最诚挚的问候,





Could someone tell me if in EF 6 DbContext automatically insert data into a Xml Column of a table after inserting data to all sparse column of the table. If I execute an INSERT statement in SQL Server only in all SPARSE columns the result is it insert also the data automatically to Xml column. How can I get the same functionalty in EF 6 DbContext?

Table structure:

Table Name: Royalty

Columns:

         Id int Primary key

         SparseCol1 sparse varchar (50) null,

         SparseCol2 sparse varchar (50) null,

         XmlCol xml column-set for all_sparse_columns

Below is the coode:

 class Program
    {
        static void Main(string[] args)
        {
       
            using (var db = new NewContext())
            {
                           

解决方案

Hi,

>>but I expect that  XmlCol should be populated. 

How does you expect the XmlCol be populated? and what is populated into the XMLCol? Since the sparse column cannot have a default value in the database, you should add the XMLCol  by code. You could do this in the property of entities .

public string xmlcol { get { return xmlcol; } set { xmlcol = "XML"; }

}

Best Regards,



这篇关于实体框架6与SQL Server表稀疏列和Xml列集为All_sparse_columns的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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