如何使用存储过程对GUID作为键字段的表执行crud操作 [英] how to use stored procedures for performing crud operations on a table with GUID as key field

查看:97
本文介绍了如何使用存储过程对GUID作为键字段的表执行crud操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有人可以告诉我如何在Guid作为关键字段的桌子上创建存储过程以执行crud操作。我对如何编写这些Sp并使用它们很困惑MVC4 EDM作为关键字段是GUID。

解决方案

创建如下创建存储过程



创建程序procname

开始

插入(id,xxx,xxx .....)

values(newid(),XXX,XXX ......)

结束



每次添加记录时,此NEWID()都会在数据库中插入新的GUID。



创建更新并删除存储过程。



按照MSDN文档将概念模型映射到存储程序



通过选择表格和你创建的SP来创建EDM。



转到你的。 edmx和rt点击你的实体选择商店程序映射

选择功能即你的用于插入,更新和删除操作的sp。

并将实体属性映射到sp参数。



构建解决方案。



现在您的EDM使用这些SP执行CRUD操作。



现在您可以创建控制器。

Hi,
can anybody tell me how do i create store procedures for performing crud operations on a table with Guid as a key field .I am confused about how to write these Sp's and use them in MVC4 EDM as the key field is a GUID.

解决方案

Create create store procedure as below

create procedure procname
begin
insert into (id,xxx,xxx.....)
values(newid(),XXX,XXX......)
end

THIS NEWID() will insert a new GUID into database each time you add a record.

create update and delete store proc's.

Follow the MSDN documentation for mapping the conceptual model to stored procedure

create the EDM by selecting the table and the SP's that you created.

goto your .edmx and rt click on your entity select store procedure mapping
select the function i.e your sp's for insert,updat and delete operations.
and map the entities properties to your sp parameters.

build the solution.

Now your EDM uses these SP's for performing CRUD operations .

Now you can create your controllers.


这篇关于如何使用存储过程对GUID作为键字段的表执行crud操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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