模型定义函数 - 返回列表/集合 [英] Model Defined Functions - Return List/Collection

查看:79
本文介绍了模型定义函数 - 返回列表/集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我读过这篇关于模型定义函数的文章(http://blogs.msdn.com/efdesign/archive/2009/01/07/model -defined-functions.aspx)。我想使用Table-Value-Function来实现权限系统。为此,我需要从我的应用程序调用一个自定义的
数据库函数(让我们称之为permissionChecker)。 permissionChecker函数获取userid作为输入,并应返回允许该用户读取的对象-id列表或表。

I have read this article about Model Defined Functions (http://blogs.msdn.com/efdesign/archive/2009/01/07/model-defined-functions.aspx). I want to use a Table-Value-Function to realize a permission system. For that I need to call from my application a custom database function (let's call it permissionChecker). The permissionChecker function gets a userid as input and should return a list or table of objects-id which this user is allowed to read.

我知道如何使用返回标量类型的自定义DB函数- 这很简单。但是如何返回ID列表(在我的例子中为GUID)。我还阅读了Julie Lerman撰写的这篇文章(http://thedatafarm.com/blog/data-access/ef4-model-defined-functions-level-1-amp-2/)。
在那里我找到了这段代码:

I know how to use custom DB functions which return scalar types - that's easy. But how can I return a list of IDs (in my case GUIDs). I have also read this article by Julie Lerman (http://thedatafarm.com/blog/data-access/ef4-model-defined-functions-level-1-amp-2/). There I found this piece of code:

 


<
ReturnType
>

< CollectionType >
< RowType >
<Property ….. />
<Property ….. />
</ RowType >
</ CollectionType >
</ ReturnType >

推荐答案

您无法对存储过程返回的结果应用转换。从存储过程返回的结果无法合成。

You cannot apply transformation on a result returned from a stored procedure. Results returned from stored procedure cannot be composed.

此外,您不能在sql server上使用表值函数,因为Entity Framework 4.0不支持

Also you cannot use table valued function on the sql server because that is not supported in Entity Framework 4.0

 

Zeeshan

 

 


这篇关于模型定义函数 - 返回列表/集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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