Asp.net核心和graphql [英] Asp.net core and graphql

查看:132
本文介绍了Asp.net核心和graphql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用graph.net.net与asp.net核心对抗真实数据库?



我尝试过:



通过graphql文档但没有正确的方向。

解决方案

GraphQL 不是关于真正的数据库访问,它是一个关注与API通信的规范,并且定义它是与数据源无关的。设置完整的Web应用程序并不是一个完整的软件包。



除了现有的基于MVC的API之外,它只是另一个控制器而且支持它连接到现有模型的服务。您可以自定义Graph查询与其关联模型之间的关系。



Redgate有一篇文章,用于使用带有Net Core的GraphQL设置项目API基础:

ASP.NET中的GraphQL入门 - 简单对话 [ ^ ]

我知道它不会过去设置它数据库,但它确实超越了基础,你只需要添加你的数据库和你想要的方法;它可以通过一个框架(实体,nHibernate)或只是普通的旧ADO或OLE。



如果你需要更多的东西, NReco 包含一个包含数据库层以使用ADO连接数据库的包。

用于SQL数据库的NReco GraphQL API (C#/。NET) [ ^ ]

how can use graphql.net with asp.net core against real database?

What I have tried:

went through graphql documentation but no proper direction.

解决方案

GraphQL is not about real database access, it is a specification concerned with communicating with an API and be definition it is data source agnostic. It is not is a "complete package" to set up a full web application.

On top of an existing MVC based API, it is simply another Controller and it backing service which connect to the existing Models. It would be up to you to define the relationship between the Graph query and it's associated Model.

Redgate has an article for setting up a project using GraphQL with a Net Core API base:
Getting Started with GraphQL in ASP.NET - Simple Talk[^]
I know it does not go over setting it up with a database but it does go over the underpinnings, you just need to add in your database and your desired method of talking to it; it could be through a framework (Entity, nHibernate) or just plain old ADO or OLE.

If you need something a little more, NReco has a package out that includes a database layer to use ADO connected databases.
NReco GraphQL API for SQL database (C#/.NET)[^]


这篇关于Asp.net核心和graphql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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