HIERARCHYID实体框架不工作 [英] HierarchyID in Entity Framework not working

查看:272
本文介绍了HIERARCHYID实体框架不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们是基于实体框架模式,为应用程序中使用WCF数据服务。

We are using WCF Data Service based on an Entity Framework model for our application.

在此,我们需要与类型的列添加表 HierarchyId的。当我的表添加到EDMX文件中的 HierarchId 列未出现在类文件。

In this we need to add the table with a column of type HierarchyId. When I add that table to the EDMX file, the HierarchId column is not appearing in the class file.

我应该怎么做,以充分利用 HIERARCHYID 的?我读了实体框架是不支持 HIERARCHYID ,所以我怎么能做到这一点?

What should I do to make use of HierarchyID? I read that Entity Framework is not supporting HierarchyID, so how can I achieve this?

推荐答案

您可以随时转换 HierarchyId的来为其字符串表示 - 类似于 / 1/3/4/1 - 发送跨WCF数据服务,串

You can always convert a HierarchyId to its string representation - something like /1/3/4/1 - and send that string across the WCF data service.

更新:如果您添加此计算,坚持列到你的SQL Server表,新列一定要在你的EF模型出现了,你应该能够使用该把它送回来了WCF和WCF数据服务:

Update: if you add this computed, persisted column to your SQL Server table, that new column should definitely show up in your EF model and you should be able to use this to send it back over WCF and WCF Data Services:

ALTER TABLE dbo.YourTable
ADD HierarchyString AS (your hierarchyID field).ToString() PERSISTED

更新#2: 阅读文档 !您可以解析回像一个字符串 / 1/3/4/1 HierarchyId的类型 - 无论是使用 HierarchyId的::解析(字符串)或通常 CAST(字符串作为HierarchyId的)的方法来做到这一点。

Update #2: read the docs! You can parse back a string like /1/3/4/1 into a HierarchyId type - either use the HierarchyId::Parse(string) or the usual CAST(string as HierarchyId) methods to do so.

这篇关于HIERARCHYID实体框架不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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