Better ToString for DataLayer objects

This commit is contained in:
Robert McRackan 2019-11-19 09:54:42 -05:00
parent f3128b562d
commit 80b0ef600d
17 changed files with 133 additions and 210 deletions

Binary file not shown.

View File

@ -3,54 +3,50 @@ using System;
using DataLayer; using DataLayer;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DataLayer.Migrations namespace DataLayer.Migrations
{ {
[DbContext(typeof(LibationContext))] [DbContext(typeof(LibationContext))]
[Migration("20191115193402_Fresh")] [Migration("20191119144803_Fresh")]
partial class Fresh partial class Fresh
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "3.0.0") .HasAnnotation("ProductVersion", "3.0.0");
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("DataLayer.Book", b => modelBuilder.Entity("DataLayer.Book", b =>
{ {
b.Property<int>("BookId") b.Property<int>("BookId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudibleProductId") b.Property<string>("AudibleProductId")
.HasColumnType("nvarchar(450)"); .HasColumnType("TEXT");
b.Property<int>("CategoryId") b.Property<int>("CategoryId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime?>("DatePublished") b.Property<DateTime?>("DatePublished")
.HasColumnType("datetime2"); .HasColumnType("TEXT");
b.Property<string>("Description") b.Property<string>("Description")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<bool>("IsAbridged") b.Property<bool>("IsAbridged")
.HasColumnType("bit"); .HasColumnType("INTEGER");
b.Property<int>("LengthInMinutes") b.Property<int>("LengthInMinutes")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("PictureId") b.Property<string>("PictureId")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<string>("Title") b.Property<string>("Title")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.HasKey("BookId"); b.HasKey("BookId");
@ -64,16 +60,16 @@ namespace DataLayer.Migrations
modelBuilder.Entity("DataLayer.BookContributor", b => modelBuilder.Entity("DataLayer.BookContributor", b =>
{ {
b.Property<int>("BookId") b.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("ContributorId") b.Property<int>("ContributorId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("Role") b.Property<int>("Role")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<byte>("Order") b.Property<byte>("Order")
.HasColumnType("tinyint"); .HasColumnType("INTEGER");
b.HasKey("BookId", "ContributorId", "Role"); b.HasKey("BookId", "ContributorId", "Role");
@ -88,17 +84,16 @@ namespace DataLayer.Migrations
{ {
b.Property<int>("CategoryId") b.Property<int>("CategoryId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudibleCategoryId") b.Property<string>("AudibleCategoryId")
.HasColumnType("nvarchar(450)"); .HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<int?>("ParentCategoryCategoryId") b.Property<int?>("ParentCategoryCategoryId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.HasKey("CategoryId"); b.HasKey("CategoryId");
@ -121,14 +116,13 @@ namespace DataLayer.Migrations
{ {
b.Property<int>("ContributorId") b.Property<int>("ContributorId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudibleAuthorId") b.Property<string>("AudibleContributorId")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(450)"); .HasColumnType("TEXT");
b.HasKey("ContributorId"); b.HasKey("ContributorId");
@ -140,10 +134,10 @@ namespace DataLayer.Migrations
modelBuilder.Entity("DataLayer.LibraryBook", b => modelBuilder.Entity("DataLayer.LibraryBook", b =>
{ {
b.Property<int>("BookId") b.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("DateAdded") b.Property<DateTime>("DateAdded")
.HasColumnType("datetime2"); .HasColumnType("TEXT");
b.HasKey("BookId"); b.HasKey("BookId");
@ -154,14 +148,13 @@ namespace DataLayer.Migrations
{ {
b.Property<int>("SeriesId") b.Property<int>("SeriesId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudibleSeriesId") b.Property<string>("AudibleSeriesId")
.HasColumnType("nvarchar(450)"); .HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.HasKey("SeriesId"); b.HasKey("SeriesId");
@ -173,13 +166,13 @@ namespace DataLayer.Migrations
modelBuilder.Entity("DataLayer.SeriesBook", b => modelBuilder.Entity("DataLayer.SeriesBook", b =>
{ {
b.Property<int>("SeriesId") b.Property<int>("SeriesId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("BookId") b.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<float?>("Index") b.Property<float?>("Index")
.HasColumnType("real"); .HasColumnType("REAL");
b.HasKey("SeriesId", "BookId"); b.HasKey("SeriesId", "BookId");
@ -201,18 +194,16 @@ namespace DataLayer.Migrations
b.OwnsOne("DataLayer.Rating", "Rating", b1 => b.OwnsOne("DataLayer.Rating", "Rating", b1 =>
{ {
b1.Property<int>("BookId") b1.Property<int>("BookId")
.ValueGeneratedOnAdd() .HasColumnType("INTEGER");
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<float>("OverallRating") b1.Property<float>("OverallRating")
.HasColumnType("real"); .HasColumnType("REAL");
b1.Property<float>("PerformanceRating") b1.Property<float>("PerformanceRating")
.HasColumnType("real"); .HasColumnType("REAL");
b1.Property<float>("StoryRating") b1.Property<float>("StoryRating")
.HasColumnType("real"); .HasColumnType("REAL");
b1.HasKey("BookId"); b1.HasKey("BookId");
@ -226,14 +217,13 @@ namespace DataLayer.Migrations
{ {
b1.Property<int>("SupplementId") b1.Property<int>("SupplementId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<int>("BookId") b1.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b1.Property<string>("Url") b1.Property<string>("Url")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b1.HasKey("SupplementId"); b1.HasKey("SupplementId");
@ -248,10 +238,10 @@ namespace DataLayer.Migrations
b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 =>
{ {
b1.Property<int>("BookId") b1.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b1.Property<string>("Tags") b1.Property<string>("Tags")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b1.HasKey("BookId"); b1.HasKey("BookId");
@ -263,16 +253,16 @@ namespace DataLayer.Migrations
b1.OwnsOne("DataLayer.Rating", "Rating", b2 => b1.OwnsOne("DataLayer.Rating", "Rating", b2 =>
{ {
b2.Property<int>("UserDefinedItemBookId") b2.Property<int>("UserDefinedItemBookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b2.Property<float>("OverallRating") b2.Property<float>("OverallRating")
.HasColumnType("real"); .HasColumnType("REAL");
b2.Property<float>("PerformanceRating") b2.Property<float>("PerformanceRating")
.HasColumnType("real"); .HasColumnType("REAL");
b2.Property<float>("StoryRating") b2.Property<float>("StoryRating")
.HasColumnType("real"); .HasColumnType("REAL");
b2.HasKey("UserDefinedItemBookId"); b2.HasKey("UserDefinedItemBookId");

View File

@ -12,7 +12,7 @@ namespace DataLayer.Migrations
columns: table => new columns: table => new
{ {
CategoryId = table.Column<int>(nullable: false) CategoryId = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Sqlite:Autoincrement", true),
AudibleCategoryId = table.Column<string>(nullable: true), AudibleCategoryId = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true), Name = table.Column<string>(nullable: true),
ParentCategoryCategoryId = table.Column<int>(nullable: true) ParentCategoryCategoryId = table.Column<int>(nullable: true)
@ -33,9 +33,9 @@ namespace DataLayer.Migrations
columns: table => new columns: table => new
{ {
ContributorId = table.Column<int>(nullable: false) ContributorId = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: true), Name = table.Column<string>(nullable: true),
AudibleAuthorId = table.Column<string>(nullable: true) AudibleContributorId = table.Column<string>(nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -47,7 +47,7 @@ namespace DataLayer.Migrations
columns: table => new columns: table => new
{ {
SeriesId = table.Column<int>(nullable: false) SeriesId = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Sqlite:Autoincrement", true),
AudibleSeriesId = table.Column<string>(nullable: true), AudibleSeriesId = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true) Name = table.Column<string>(nullable: true)
}, },
@ -61,7 +61,7 @@ namespace DataLayer.Migrations
columns: table => new columns: table => new
{ {
BookId = table.Column<int>(nullable: false) BookId = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Sqlite:Autoincrement", true),
AudibleProductId = table.Column<string>(nullable: true), AudibleProductId = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true), Title = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true), Description = table.Column<string>(nullable: true),
@ -159,7 +159,7 @@ namespace DataLayer.Migrations
columns: table => new columns: table => new
{ {
SupplementId = table.Column<int>(nullable: false) SupplementId = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Sqlite:Autoincrement", true),
BookId = table.Column<int>(nullable: false), BookId = table.Column<int>(nullable: false),
Url = table.Column<string>(nullable: true) Url = table.Column<string>(nullable: true)
}, },

View File

@ -3,7 +3,6 @@ using System;
using DataLayer; using DataLayer;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DataLayer.Migrations namespace DataLayer.Migrations
@ -15,40 +14,37 @@ namespace DataLayer.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "3.0.0") .HasAnnotation("ProductVersion", "3.0.0");
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("DataLayer.Book", b => modelBuilder.Entity("DataLayer.Book", b =>
{ {
b.Property<int>("BookId") b.Property<int>("BookId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudibleProductId") b.Property<string>("AudibleProductId")
.HasColumnType("nvarchar(450)"); .HasColumnType("TEXT");
b.Property<int>("CategoryId") b.Property<int>("CategoryId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime?>("DatePublished") b.Property<DateTime?>("DatePublished")
.HasColumnType("datetime2"); .HasColumnType("TEXT");
b.Property<string>("Description") b.Property<string>("Description")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<bool>("IsAbridged") b.Property<bool>("IsAbridged")
.HasColumnType("bit"); .HasColumnType("INTEGER");
b.Property<int>("LengthInMinutes") b.Property<int>("LengthInMinutes")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<string>("PictureId") b.Property<string>("PictureId")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<string>("Title") b.Property<string>("Title")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.HasKey("BookId"); b.HasKey("BookId");
@ -62,16 +58,16 @@ namespace DataLayer.Migrations
modelBuilder.Entity("DataLayer.BookContributor", b => modelBuilder.Entity("DataLayer.BookContributor", b =>
{ {
b.Property<int>("BookId") b.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("ContributorId") b.Property<int>("ContributorId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("Role") b.Property<int>("Role")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<byte>("Order") b.Property<byte>("Order")
.HasColumnType("tinyint"); .HasColumnType("INTEGER");
b.HasKey("BookId", "ContributorId", "Role"); b.HasKey("BookId", "ContributorId", "Role");
@ -86,17 +82,16 @@ namespace DataLayer.Migrations
{ {
b.Property<int>("CategoryId") b.Property<int>("CategoryId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudibleCategoryId") b.Property<string>("AudibleCategoryId")
.HasColumnType("nvarchar(450)"); .HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<int?>("ParentCategoryCategoryId") b.Property<int?>("ParentCategoryCategoryId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.HasKey("CategoryId"); b.HasKey("CategoryId");
@ -119,14 +114,13 @@ namespace DataLayer.Migrations
{ {
b.Property<int>("ContributorId") b.Property<int>("ContributorId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudibleAuthorId") b.Property<string>("AudibleContributorId")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(450)"); .HasColumnType("TEXT");
b.HasKey("ContributorId"); b.HasKey("ContributorId");
@ -138,10 +132,10 @@ namespace DataLayer.Migrations
modelBuilder.Entity("DataLayer.LibraryBook", b => modelBuilder.Entity("DataLayer.LibraryBook", b =>
{ {
b.Property<int>("BookId") b.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<DateTime>("DateAdded") b.Property<DateTime>("DateAdded")
.HasColumnType("datetime2"); .HasColumnType("TEXT");
b.HasKey("BookId"); b.HasKey("BookId");
@ -152,14 +146,13 @@ namespace DataLayer.Migrations
{ {
b.Property<int>("SeriesId") b.Property<int>("SeriesId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AudibleSeriesId") b.Property<string>("AudibleSeriesId")
.HasColumnType("nvarchar(450)"); .HasColumnType("TEXT");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.HasKey("SeriesId"); b.HasKey("SeriesId");
@ -171,13 +164,13 @@ namespace DataLayer.Migrations
modelBuilder.Entity("DataLayer.SeriesBook", b => modelBuilder.Entity("DataLayer.SeriesBook", b =>
{ {
b.Property<int>("SeriesId") b.Property<int>("SeriesId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<int>("BookId") b.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.Property<float?>("Index") b.Property<float?>("Index")
.HasColumnType("real"); .HasColumnType("REAL");
b.HasKey("SeriesId", "BookId"); b.HasKey("SeriesId", "BookId");
@ -199,18 +192,16 @@ namespace DataLayer.Migrations
b.OwnsOne("DataLayer.Rating", "Rating", b1 => b.OwnsOne("DataLayer.Rating", "Rating", b1 =>
{ {
b1.Property<int>("BookId") b1.Property<int>("BookId")
.ValueGeneratedOnAdd() .HasColumnType("INTEGER");
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<float>("OverallRating") b1.Property<float>("OverallRating")
.HasColumnType("real"); .HasColumnType("REAL");
b1.Property<float>("PerformanceRating") b1.Property<float>("PerformanceRating")
.HasColumnType("real"); .HasColumnType("REAL");
b1.Property<float>("StoryRating") b1.Property<float>("StoryRating")
.HasColumnType("real"); .HasColumnType("REAL");
b1.HasKey("BookId"); b1.HasKey("BookId");
@ -224,14 +215,13 @@ namespace DataLayer.Migrations
{ {
b1.Property<int>("SupplementId") b1.Property<int>("SupplementId")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("INTEGER");
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<int>("BookId") b1.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b1.Property<string>("Url") b1.Property<string>("Url")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b1.HasKey("SupplementId"); b1.HasKey("SupplementId");
@ -246,10 +236,10 @@ namespace DataLayer.Migrations
b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 =>
{ {
b1.Property<int>("BookId") b1.Property<int>("BookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b1.Property<string>("Tags") b1.Property<string>("Tags")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b1.HasKey("BookId"); b1.HasKey("BookId");
@ -261,16 +251,16 @@ namespace DataLayer.Migrations
b1.OwnsOne("DataLayer.Rating", "Rating", b2 => b1.OwnsOne("DataLayer.Rating", "Rating", b2 =>
{ {
b2.Property<int>("UserDefinedItemBookId") b2.Property<int>("UserDefinedItemBookId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b2.Property<float>("OverallRating") b2.Property<float>("OverallRating")
.HasColumnType("real"); .HasColumnType("REAL");
b2.Property<float>("PerformanceRating") b2.Property<float>("PerformanceRating")
.HasColumnType("real"); .HasColumnType("REAL");
b2.Property<float>("StoryRating") b2.Property<float>("StoryRating")
.HasColumnType("real"); .HasColumnType("REAL");
b2.HasKey("UserDefinedItemBookId"); b2.HasKey("UserDefinedItemBookId");

View File

@ -246,5 +246,7 @@ namespace DataLayer
context.Entry(this).Reference(s => s.Category).Load(); context.Entry(this).Reference(s => s.Category).Load();
Category = category; Category = category;
} }
public override string ToString() => $"[{AudibleProductId}] {Title}";
} }
} }

View File

@ -23,5 +23,7 @@ namespace DataLayer
Role = role; Role = role;
Order = order; Order = order;
} }
public override string ToString() => $"{Book} {Contributor} {Role} {Order}";
} }
} }

View File

@ -48,5 +48,7 @@ namespace DataLayer
if (parentCategory != null) if (parentCategory != null)
ParentCategory = parentCategory; ParentCategory = parentCategory;
} }
public override string ToString() => $"[{AudibleCategoryId}] {Name}";
} }
} }

View File

@ -25,6 +25,8 @@ namespace DataLayer
private HashSet<BookContributor> _booksLink; private HashSet<BookContributor> _booksLink;
public IEnumerable<BookContributor> BooksLink => _booksLink?.ToList(); public IEnumerable<BookContributor> BooksLink => _booksLink?.ToList();
public string AudibleContributorId { get; private set; }
private Contributor() { } private Contributor() { }
public Contributor(string name) public Contributor(string name)
{ {
@ -34,49 +36,13 @@ namespace DataLayer
Name = name; Name = name;
} }
public Contributor(string name, string audibleContributorId) : this(name)
public string AudibleAuthorId { get; private set; }
public void UpdateAudibleAuthorId(string authorId)
{ {
// don't overwrite with null or whitespace but not an error // don't overwrite with null or whitespace but not an error
if (!string.IsNullOrWhiteSpace(authorId)) if (!string.IsNullOrWhiteSpace(audibleContributorId))
AudibleAuthorId = authorId; AudibleContributorId = audibleContributorId;
} }
#region // AudibleAuthorId refactor: separate author-specific info. overkill for a single optional string public override string ToString() => Name;
///// <summary>Most authors in Audible have a unique id</summary>
//public AudibleAuthorProperty AudibleAuthorProperty { get; private set; }
//public void UpdateAuthorId(string authorId, LibationContext context = null)
//{
// if (authorId == null)
// return;
// if (AudibleAuthorProperty != null)
// {
// AudibleAuthorProperty.UpdateAudibleAuthorId(authorId);
// return;
// }
// if (context == null)
// throw new ArgumentNullException(nameof(context), "You must provide a context");
// if (context.Contributors.Find(ContributorId) == null)
// throw new InvalidOperationException("Could not update audible author id.");
// var audibleAuthorProperty = new AudibleAuthorProperty();
// audibleAuthorProperty.UpdateAudibleAuthorId(authorId);
// context.AuthorProperties.Add(audibleAuthorProperty);
//}
//public class AudibleAuthorProperty
//{
// public int ContributorId { get; private set; }
// public Contributor Contributor { get; set; }
// public string AudibleAuthorId { get; private set; }
// public void UpdateAudibleAuthorId(string authorId)
// {
// if (!string.IsNullOrWhiteSpace(authorId))
// AudibleAuthorId = authorId;
// }
//}
//// ...and create EF table config
#endregion
} }
} }

View File

@ -17,5 +17,7 @@ namespace DataLayer
Book = book; Book = book;
DateAdded = dateAdded; DateAdded = dateAdded;
} }
public override string ToString() => $"{DateAdded:d} {Book}";
} }
} }

View File

@ -72,5 +72,7 @@ namespace DataLayer
return string.Join("\r\n", items); return string.Join("\r\n", items);
} }
public override string ToString() => $"Overall={OverallRating} Perf={PerformanceRating} Story={StoryRating}";
} }
} }

View File

@ -66,5 +66,7 @@ namespace DataLayer
if (_booksLink.SingleOrDefault(sb => sb.Book == book) == null) if (_booksLink.SingleOrDefault(sb => sb.Book == book) == null)
_booksLink.Add(new SeriesBook(this, book, index)); _booksLink.Add(new SeriesBook(this, book, index));
} }
public override string ToString() => Name;
} }
} }

View File

@ -34,5 +34,7 @@ namespace DataLayer
if (index.HasValue) if (index.HasValue)
Index = index.Value; Index = index.Value;
} }
public override string ToString() => $"Series={Series} Book={Book}";
} }
} }

View File

@ -20,5 +20,7 @@ namespace DataLayer
Book = book; Book = book;
Url = url; Url = url;
} }
public override string ToString() => $"{Book} {Url.Substring(Url.Length - 4)}";
} }
} }

View File

@ -78,5 +78,7 @@ namespace DataLayer
public void UpdateRating(float overallRating, float performanceRating, float storyRating) public void UpdateRating(float overallRating, float performanceRating, float storyRating)
=> Rating.Update(overallRating, performanceRating, storyRating); => Rating.Update(overallRating, performanceRating, storyRating);
public override string ToString() => $"{Book} {Rating} {Tags}";
} }
} }

View File

@ -67,11 +67,9 @@ namespace DtoImporterService
var person = context.Contributors.Local.SingleOrDefault(c => c.Name == p.Name); var person = context.Contributors.Local.SingleOrDefault(c => c.Name == p.Name);
if (person == null) if (person == null)
{ {
person = context.Contributors.Add(new Contributor(p.Name)).Entity; person = context.Contributors.Add(new Contributor(p.Name, p.Asin)).Entity;
qtyNew++; qtyNew++;
} }
person.UpdateAudibleAuthorId(p.Asin);
} }
return qtyNew; return qtyNew;

View File

@ -32,7 +32,7 @@ namespace LibationWinForm
public ProductsGrid() public ProductsGrid()
{ {
InitializeComponent(); InitializeComponent();
Disposed += (_, __) => { if (context != null) context.Dispose(); }; Disposed += (_, __) => context?.Dispose();
} }
private bool hasBeenDisplayed = false; private bool hasBeenDisplayed = false;

View File

@ -1,6 +1,7 @@
-- begin VERSIONING --------------------------------------------------------------------------------------------------------------------- -- begin VERSIONING ---------------------------------------------------------------------------------------------------------------------
https://github.com/rmcrackan/Libation/releases https://github.com/rmcrackan/Libation/releases
v3.1-beta.2 : fixed known performance issue: Tag add/edit
v3.1-beta.1 : RELEASE TO BETA v3.1-beta.1 : RELEASE TO BETA
v3.0.3 : Switch to SQLite. No longer relies on LocalDB, which must be installed separately v3.0.3 : Switch to SQLite. No longer relies on LocalDB, which must be installed separately
v3.0.2 : Final using LocalDB v3.0.2 : Final using LocalDB
@ -38,19 +39,6 @@ alternate book id (eg BK_RAND_006061) is called 'sku' , 'sku_lite' , 'prod_id' ,
-- end AUDIBLE DETAILS --------------------------------------------------------------------------------------------------------------------- -- end AUDIBLE DETAILS ---------------------------------------------------------------------------------------------------------------------
-- begin SOLUTION LAYOUT --------------------------------------------------------------------------------------------------------------------- -- begin SOLUTION LAYOUT ---------------------------------------------------------------------------------------------------------------------
core libraries
extend Standard Libraries
additional simple libraries for general purpose programming
utils: domain ignorant
domain: biz logic
db ignorant
db, domain objects
domain internal utilities: domain aware. db ignorant
domain utilities: domain aware. db aware
incl non-db persistence. unless it needs to be tied into a db intercepter
all user-provided data must be backed up to json
application
do NOT combine jsons for do NOT combine jsons for
- audible-scraped persistence: library, book details - audible-scraped persistence: library, book details
- libation-generated persistence: FilePaths.json - libation-generated persistence: FilePaths.json
@ -74,31 +62,4 @@ aggregate root is transactional boundary
// // test with and without : using TransactionScope scope = new TransactionScope(); // // test with and without : using TransactionScope scope = new TransactionScope();
//System.Transactions.Transaction.Current.TransactionCompleted += (sender, e) => { }; //System.Transactions.Transaction.Current.TransactionCompleted += (sender, e) => { };
// also : https://docs.microsoft.com/en-us/dotnet/api/system.transactions.transaction.enlistvolatile // also : https://docs.microsoft.com/en-us/dotnet/api/system.transactions.transaction.enlistvolatile
pattern when using 1 db context per form
public Ctor()
{
InitializeComponent();
// dispose context here only. DO NOT dispose in OnParentChanged(). parent form will call dispose after this one has been switched.
// disposing context prematurely can result in:
// The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
this.Disposed += (_, __) => context?.Dispose();
}
-- end EF CORE --------------------------------------------------------------------------------------------------------------------- -- end EF CORE ---------------------------------------------------------------------------------------------------------------------
-- begin ASYNC/AWAIT ---------------------------------------------------------------------------------------------------------------------
Using Async and Await to update the UI Thread Stephen Haunts { Coding in the Trenches }
https://stephenhaunts.com/2014/10/14/using-async-and-await-to-update-the-ui-thread/
Using Async and Await to update the UI Thread Part 2 Stephen Haunts { Coding in the Trenches }
https://stephenhaunts.com/2014/10/16/using-async-and-await-to-update-the-ui-thread-part-2/
Simple Async Await Example for Asynchronous Programming Stephen Haunts { Coding in the Trenches }
https://stephenhaunts.com/2014/10/10/simple-async-await-example-for-asynchronous-programming/
Async and Await -- Stephen Cleary's famous intro
https://blog.stephencleary.com/2012/02/async-and-await.html
Async-Await - Best Practices in Asynchronous Programming -- Stephen Cleary
https://msdn.microsoft.com/en-us/magazine/jj991977.aspx
-- end ASYNC/AWAIT ---------------------------------------------------------------------------------------------------------------------