admin管理员组

文章数量:1389897

I have this entity (I left only relevant fields):

type UserSession = {
    Id: string
    CreatedAt: DateTime
    LastRefreshAt: DateTime option
}

and in my UserSessionRepository.fs I have this function:

member this.DeleteAbandoned (olderThen:DateTime) =               
    base.Delete (fun session -> 
        session.CreatedAt < olderThen &&
        // error: Value is not a property of UserSession
        (session.LastRefreshAt.IsNone || session.LastRefreshAt.Value < olderThen)
    )
    |> ignore

I get the error "Value is not defined as a property of UserSession" (kind of).

I changed it, trying to avoid using the .Value property:

member this.DeleteAbandoned (olderThen:DateTime) =               
    base.Delete (fun session -> 
        session.CreatedAt < olderThen &&
        // error: Object reference not set to an instance of an object
        (session.LastRefreshAt.IsNone || session.LastRefreshAt < Some(olderThen))
    )
    |> ignore

but this raises the error "Object reference not set to an instance of an object".

How to solve it?

RepoDB 10.x
9

本文标签: fDelete function with where clause on a optionStack Overflow