Fauna v10 .NET/C# Driver 0.3.0-beta
 
Loading...
Searching...
No Matches
BaseRefBuilder.cs
Go to the documentation of this file.
1namespace Fauna.Types;
2
3public class BaseRefBuilder<T>
4{
5 public string? Id { get; set; }
6 public string? Name { get; set; }
7 public Module? Collection { get; set; }
8 public string? Cause { get; set; }
9 public bool? Exists { get; set; }
10 public T? Doc { get; set; }
11
13 {
14 if (Collection is null) throw new ArgumentNullException(nameof(Collection));
15
16 if (Id is not null)
17 {
18 if (Exists != null && !Exists.Value) return new Ref<T>(Id, Collection, Cause ?? "");
19 if (Doc != null) return new Ref<T>(Id, Collection, Doc);
20 return new Ref<T>(Id, Collection);
21 }
22
23 if (Name is not null)
24 {
25 if (Exists != null && !Exists.Value) return new NamedRef<T>(Name, Collection, Cause ?? "");
26 if (Doc != null) return new NamedRef<T>(Name, Collection, Doc);
27 return new NamedRef<T>(Name, Collection);
28 }
29
30 throw new ArgumentException("Id and Name cannot both be null");
31 }
32}
System.ArgumentException ArgumentException
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
Represents a document ref.
Definition Ref.cs:11