F#LiteDB[<;BsonIgnore>;]是否被忽略?
上下文:在集装箱化环境中运行F#F#LiteDB[<;BsonIgnore>;]是否被忽略?,f#,attributes,bson,litedb,F#,Attributes,Bson,Litedb,上下文:在集装箱化环境中运行F# $ dotnet --version 2.2.203 $ uname -a Linux SAFE 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 GNU/Linux 在Ubuntu 18.04桌面计算机上 此简单代码忽略[]属性。Ignore的值存储在LiteDB中。我做错什么了吗? 我已通过控制台命令查看它$dotnet LiteDB.Shell.dll micompan
$ dotnet --version 2.2.203
$ uname -a
Linux SAFE 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 GNU/Linux
在Ubuntu 18.04桌面计算机上
此简单代码忽略[]
属性。Ignore
的值存储在LiteDB中。我做错什么了吗?
我已通过控制台命令查看它$dotnet LiteDB.Shell.dll micompany.db
:
...
> open micompany.db
> db.computers.find
[1]: {"_id":11,"Ignore":"ignore","Manufacturer":"Computers Inc.","Disks":[{"SizeGb":100},{"SizeGb":250},{"SizeGb":500}]}
代码如下:
open System
open LiteDB
open LiteDB.FSharp
[<StructuredFormatDisplay("{SizeGb}GB")>]
[<CLIMutable>]
type Disk =
{ SizeGb : int }
[<StructuredFormatDisplay("Computer #{Id}: {Manufacturer}/{Disks}")>]
[<CLIMutable>]
type Computer =
{ Id: int
[<BsonIgnore>] Ignore : string
Manufacturer: string
Disks: Disk list }
[<EntryPoint>]
let main argv =
let myPc =
{ Id = 0
Ignore = "ignore"
Manufacturer = "Computers Inc."
Disks =
[ { SizeGb = 100 }
{ SizeGb = 250 }
{ SizeGb = 500 } ] }
let mapper = FSharpBsonMapper()
use db = new LiteDatabase("micompany.db", mapper)
let computers = db.GetCollection<Computer>("computers")
// Insert & Print
computers.Insert(myPc) |> ignore
printfn "%A" myPc
0 // return an integer exit code
我还有什么要说的吗
Computer #12: Computers Inc./[...GB; ...GB; ...GB]