Fauna v10 .NET/C# Driver 1.0.1
 
Loading...
Searching...
No Matches
NamedRef.cs
Go to the documentation of this file.
2using Fauna.Linq;
3
4namespace Fauna.Types;
5
6
11public class NamedRef<T> : BaseRef<T>
12{
16 public string Name { get; }
17
23 public NamedRef(string name, DataContext.ICollection col) : base(col)
24 {
25 Name = name;
26 }
27
34 public NamedRef(string name, DataContext.ICollection col, T doc) : base(col, doc)
35 {
36 Name = name;
37 }
38
45 public NamedRef(string name, DataContext.ICollection col, string cause) : base(col, cause)
46 {
47 Name = name;
48 }
49
55 public NamedRef(string name, Module col) : base(col)
56 {
57 Name = name;
58 }
59
66 public NamedRef(string name, Module col, string cause) : base(col, cause)
67 {
68 Name = name;
69 }
70
77 public NamedRef(string name, Module col, T doc) : base(col, doc)
78 {
79 Name = name;
80 }
81
85 public override T Get()
86 {
87 if (!IsLoaded) throw new UnloadedRefException();
88 if (Exists.HasValue && !Exists.Value) throw new NullDocumentException(null, Name, 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 that has a "name" instead of an "id". For example, a Role document referenc...
Definition NamedRef.cs:12
override T Get()
Definition NamedRef.cs:85
string Name
Gets the string value of the ref name.
Definition NamedRef.cs:16
NamedRef(string name, Module col, T doc)
Initializes a new instance of a loaded NamedRef<T> class.
Definition NamedRef.cs:77
NamedRef(string name, DataContext.ICollection col, string cause)
Initializes a new instance of a loaded and non-existent NamedRef<T> class.
Definition NamedRef.cs:45
NamedRef(string name, Module col)
Initializes a new instance of an unloaded NamedRef<T> class.
Definition NamedRef.cs:55
NamedRef(string name, DataContext.ICollection col)
Initializes a new instance of an unloaded NamedRef<T> class.
Definition NamedRef.cs:23
NamedRef(string name, Module col, string cause)
Initializes a new instance of a loaded and non-existent NamedRef<T> class.
Definition NamedRef.cs:66
NamedRef(string name, DataContext.ICollection col, T doc)
Initializes a new instance of a loaded NamedRef<T> class.
Definition NamedRef.cs:34
An interface for a Fauna collection within a DataContext.