Fauna v10 .NET/C# Driver 1.0.1
 
Loading...
Searching...
No Matches
Ref.cs
Go to the documentation of this file.
2using Fauna.Linq;
3
4namespace Fauna.Types;
5
6
10public class Ref<T> : BaseRef<T>
11{
15 public string Id { get; }
16
22 public Ref(string id, DataContext.ICollection col) : base(col)
23 {
24 Id = id;
25 }
26
33 public Ref(string id, DataContext.ICollection col, T doc) : base(col, doc)
34 {
35 Id = id;
36 }
37
44 public Ref(string id, DataContext.ICollection col, string cause) : base(col, cause)
45 {
46 Id = id;
47 }
48
54 public Ref(string id, Module col) : base(col)
55 {
56 Id = id;
57 }
58
65 public Ref(string id, Module col, string cause) : base(col, cause)
66 {
67 Id = id;
68 }
69
76 public Ref(string id, Module col, T doc) : base(col, doc)
77 {
78 Id = id;
79 }
80
81
85 public override T Get()
86 {
87 if (!IsLoaded) throw new UnloadedRefException();
88 if (Exists.HasValue && !Exists.Value) throw new NullDocumentException(Id, null, Collection, Cause ?? "");
89 return Doc!;
90 }
91}
An exception representing a case when a document cannot be materialized because it does not exist.
An abstract class representing a DataContext. This is a special type of Fauna client that can be used...
An abstract class representing a reference that can wrap an instance of the referenced document.
Definition BaseRef.cs:10
readonly? T Doc
Gets the materialized document represented by the Ref. Is null unless IsLoaded is true and Exists is ...
Definition BaseRef.cs:16
string? Cause
Gets the cause when exists is false. Is null unless IsLoaded is true and Exists is false.
Definition BaseRef.cs:21
bool IsLoaded
Gets a boolean indicating whether the document represented by the ref has been loaded.
Definition BaseRef.cs:36
Module Collection
Gets the collection to which the ref belongs.
Definition BaseRef.cs:26
bool? Exists
Gets a boolean indicating whether the doc exists. Is null unless IsLoaded is true.
Definition BaseRef.cs:31
Represents a module, a singleton object grouping related functionalities. Modules are serialized as @...
Definition Module.cs:8
Represents a document ref.
Definition Ref.cs:11
string Id
Gets the string value of the ref ID.
Definition Ref.cs:15
Ref(string id, Module col, T doc)
Initializes a new instance of a loaded Ref<T> class.
Definition Ref.cs:76
Ref(string id, DataContext.ICollection col)
Initializes a new instance of an unloaded Ref<T> class.
Definition Ref.cs:22
override T Get()
Definition Ref.cs:85
Ref(string id, DataContext.ICollection col, string cause)
Initializes a new instance of a loaded and non-existent Ref<T> class.
Definition Ref.cs:44
Ref(string id, DataContext.ICollection col, T doc)
Initializes a new instance of a loaded Ref<T> class.
Definition Ref.cs:33
Ref(string id, Module col, string cause)
Initializes a new instance of a loaded and non-existent Ref<T> class.
Definition Ref.cs:65
Ref(string id, Module col)
Initializes a new instance of an unloaded Ref<T> class.
Definition Ref.cs:54
An interface for a Fauna collection within a DataContext.