protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); // some of the data models don't have OnModelCreating for now, commenting them AddressInvoiceData.OnModelCreating(builder); APIKeyData.OnModelCreating(builder); AppData.OnModelCreating(builder); //StoredFile.OnModelCreating(builder); HistoricalAddressInvoiceData.OnModelCreating(builder); InvoiceEventData.OnModelCreating(builder); InvoiceSearchData.OnModelCreating(builder); InvoiceWebhookDeliveryData.OnModelCreating(builder); InvoiceData.OnModelCreating(builder); NotificationData.OnModelCreating(builder); //OffchainTransactionData.OnModelCreating(builder); Data.PairedSINData.OnModelCreating(builder); PairingCodeData.OnModelCreating(builder); //PayjoinLock.OnModelCreating(builder); PaymentRequestData.OnModelCreating(builder); PaymentData.OnModelCreating(builder); PayoutData.OnModelCreating(builder); PendingInvoiceData.OnModelCreating(builder); //PlannedTransaction.OnModelCreating(builder); PullPaymentData.OnModelCreating(builder); RefundData.OnModelCreating(builder); //SettingData.OnModelCreating(builder); StoreWebhookData.OnModelCreating(builder); //StoreData.OnModelCreating(builder); U2FDevice.OnModelCreating(builder); Fido2Credential.OnModelCreating(builder); Data.UserStore.OnModelCreating(builder); //WalletData.OnModelCreating(builder); WalletTransactionData.OnModelCreating(builder); WebhookDeliveryData.OnModelCreating(builder); //WebhookData.OnModelCreating(builder); if (Database.IsSqlite() && !_designTime) { // SQLite does not have proper support for DateTimeOffset via Entity Framework Core, see the limitations // here: https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations#query-limitations // To work around this, when the Sqlite database provider is used, all model properties of type DateTimeOffset // use the DateTimeOffsetToBinaryConverter // Based on: https://github.com/aspnet/EntityFrameworkCore/issues/10784#issuecomment-415769754 // This only supports millisecond precision, but should be sufficient for most use cases. foreach (var entityType in builder.Model.GetEntityTypes()) { var properties = entityType.ClrType.GetProperties().Where(p => p.PropertyType == typeof(DateTimeOffset)); foreach (var property in properties) { builder .Entity(entityType.Name) .Property(property.Name) .HasConversion(new Microsoft.EntityFrameworkCore.Storage.ValueConversion.DateTimeOffsetToBinaryConverter()); } } } }
public static void SetBlobInfo(this WalletTransactionData walletTransactionData, WalletTransactionInfo blobInfo) { if (blobInfo == null) { walletTransactionData.Labels = string.Empty; walletTransactionData.Blob = Array.Empty <byte>(); return; } walletTransactionData.Labels = JArray.FromObject(blobInfo.Labels).ToString(); walletTransactionData.Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo)); }
public static WalletTransactionInfo GetBlobInfo(this WalletTransactionData walletTransactionData) { if (walletTransactionData.Blob == null || walletTransactionData.Blob.Length == 0) { return(new WalletTransactionInfo()); } var blobInfo = JsonConvert.DeserializeObject <WalletTransactionInfo>(ZipUtils.Unzip(walletTransactionData.Blob)); if (!string.IsNullOrEmpty(walletTransactionData.Labels)) { blobInfo.Labels.AddRange(walletTransactionData.Labels.Split(',', StringSplitOptions.RemoveEmptyEntries)); } return(blobInfo); }
public static void SetBlobInfo(this WalletTransactionData walletTransactionData, WalletTransactionInfo blobInfo) { if (blobInfo == null) { walletTransactionData.Labels = string.Empty; walletTransactionData.Blob = Array.Empty <byte>(); return; } walletTransactionData.Labels = new JArray( blobInfo.Labels.Select(l => JsonConvert.SerializeObject(l.Value, LabelSerializerSettings)) .Select(l => JObject.Parse(l)) .OfType <JToken>() .ToArray()).ToString(); walletTransactionData.Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo)); }
public static void SetBlobInfo(this WalletTransactionData walletTransactionData, WalletTransactionInfo blobInfo) { if (blobInfo == null) { walletTransactionData.Labels = string.Empty; walletTransactionData.Blob = Array.Empty <byte>(); return; } if (blobInfo.Labels.Any(l => l.Contains(',', StringComparison.OrdinalIgnoreCase))) { throw new ArgumentException(paramName: nameof(blobInfo), message: "Labels must not contains ','"); } walletTransactionData.Labels = String.Join(',', blobInfo.Labels); walletTransactionData.Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo)); }
public static WalletTransactionInfo GetBlobInfo(this WalletTransactionData walletTransactionData) { WalletTransactionInfo blobInfo; if (walletTransactionData.Blob == null || walletTransactionData.Blob.Length == 0) { blobInfo = new WalletTransactionInfo(); } else { blobInfo = JsonConvert.DeserializeObject <WalletTransactionInfo>(ZipUtils.Unzip(walletTransactionData.Blob)); } if (!string.IsNullOrEmpty(walletTransactionData.Labels)) { if (walletTransactionData.Labels.StartsWith('[')) { foreach (var jtoken in JArray.Parse(walletTransactionData.Labels)) { var l = jtoken.Type == JTokenType.String ? Label.Parse(jtoken.Value <string>()) : Label.Parse(jtoken.ToString()); blobInfo.Labels.TryAdd(l.Text, l); } } else { // Legacy path foreach (var token in walletTransactionData.Labels.Split(',', StringSplitOptions.RemoveEmptyEntries)) { var l = Label.Parse(token); blobInfo.Labels.TryAdd(l.Text, l); } } } return(blobInfo); }