小编Den*_*mit的帖子

使用记录类型的F#WebApi不提供所需的XML输出

工作代码是这个问题的底部!

使用F#中的以下WebApi控制器:

namespace FsWeb.Controllers

open System.Web
open System.Web.Mvc
open System.Net.Http
open System.Web.Http
open Microsoft.FSharp.Linq;
open Microsoft.FSharp.Data.TypeProviders;

type dbSchema = SqlDataConnection<"conn string">

[<CLIMutable>] 
type ViewModelRec = { CustomerId : string }

type ValuesController() =
    inherit ApiController()
    let db = dbSchema.GetDataContext()
    do
        db.DataContext.Log <- System.Console.Out

    // GET /api/values
    member x.Get(take:int, skip:int) = 
        let t = take
        let s = skip

        query {
            for row in db.Reservations do
            skip s 
            take t
            select { CustomerId = row.CustomerId.ToString() }
        }
Run Code Online (Sandbox Code Playgroud)

XML输出是:

<ArrayOfViewModelRec xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/FsWeb.Controllers"> …
Run Code Online (Sandbox Code Playgroud)

f# f#-3.0 asp.net-web-api

4
推荐指数
1
解决办法
669
查看次数

标签 统计

asp.net-web-api ×1

f# ×1

f#-3.0 ×1