DotNetNext / SqlSugar

.Net aot ORM Fastest ORM Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping
https://www.donet5.com/Home/Doc
MIT License
5.28k stars 1.33k forks source link

實作OData的可行性 #1257

Closed Yumitoya8569 closed 2 months ago

Yumitoya8569 commented 2 months ago

目前OData庫大多需要IQueryable介面 且官方AspNetCoreOData這個項目問題實在太多, 幾乎不可用

因此想了解一下SqlSugar目前是否有足夠的彈性能夠實作OData? 主要是以下兩個核心類別的功能:

  1. ODataQueryOption<T>
  2. Delta<T>

能否給予建議?

DotNetNext commented 2 months ago

https://www.donet5.com/Home/Doc?typeId=2421 sqlsugar有自已的一套低代码

Yumitoya8569 commented 2 months ago

稍微研究了一下 $expand 好像無法被實作的樣子? $expand 允許嵌套查詢, 例如在$expand裡又一層$select或$expand

DotNetNext commented 2 months ago

你是 select 子查询 as name 还是 join (select xx) 这2种都支持

DotNetNext commented 2 months ago

qureyable.ToSql() 就能拿到SQL和参数这样就能嵌套了

Yumitoya8569 commented 2 months ago

$expand是導航, 只是允許再對導航作$select / $filter / $expand

例子:

?$select=f1,f2&$filter=f1 eq '1'&$expand=nav1($select=n1,n2;$expand=nav2)
DotNetNext commented 2 months ago

你可以用代码来讲解,你这样我不清楚什么样子

Yumitoya8569 commented 2 months ago

到目前還沒有到代碼層面 而是探討OData v4規範實作的可行性

假設有這麼一組原始資料, 其中Orders是導航屬性

{
  "value": [
    {
      "CustomerID": 1,
      "Orders": [
        {
          "OrderID": 101
        }
        ...
      ]
    }
    ...
  ]
}

指定過濾條件

GET /odata/Customers?$filter=CustomerID eq 4

得到結果:

{
  "value": [
    {
      "CustomerID": 4
    }
  ]
}

以此為基礎再指定導航與導航的過濾條件

GET /odata/Customers?$filter=CustomerID eq 4&$expand=Orders($filter=OrderID eq 402)

得到結果:

{
  "value": [
    {
      "CustomerID": 4,
      "Orders": [
        {
          "OrderID": 402
        }
      ]
    }    
  ]
}
DotNetNext commented 2 months ago

https://www.donet5.com/Home/Doc?typeId=2562

你看一下标题5

可以用动态类实现

Yumitoya8569 commented 2 months ago

大致上有頭緒了 謝謝

DotNetNext commented 2 months ago

还有问题吗,没有就关闭了

DotNetNext commented 2 months ago

先关闭还有疑问发新的ISSUE