🚀 Add some stuffs

WORK-EF_WebAPI
Antoine PEREDERII 1 year ago
parent 4104dbd5fa
commit 905cbef374

@ -8,7 +8,7 @@
using Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
namespace DbContextLib
{

@ -6,9 +6,9 @@ public class FriendshipEntity
{
[ForeignKey("FollowingId")]
public int FollowingId { get; set; }
public AthleteEntity Following { get; set; }
public AthleteEntity Following { get; set; } = null!;
[ForeignKey("FollowerId")]
public int FollowerId { get; set; }
public AthleteEntity Follower { get; set; }
public AthleteEntity Follower { get; set; } = null!;
public DateTime StartDate { get; set; }
}

@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations;
public class Picture
{
[Key]
public Guid Id { get; set; }
[Required]
public byte[] Bytes { get; set; }
public byte[] Bytes { get; set; } = null!;
}

@ -15,6 +15,21 @@ public partial class DbDataManager
public async Task<IEnumerable<Activity>> GetItems(int index, int count, Enum? orderingProperty = null, bool descending = false)
{
// public class MyLogger
// {
// public void Log(string component, string message)
// {
// Console.WriteLine("Component: {0} Message: {1} ", component, message);
// }
// }
// ? Utilisation du logger !!!
//! using (var context = new LibraryContext())
//! {
// var logger = new MyLogger();
// context.Database.Log = s => logger.Log("EFApp", s);
//! // log la connexion à la base de donnée
//! context.Database.Log = Console.Write;
//! }
throw new NotImplementedException();
}

@ -0,0 +1,27 @@
// using System;
// using Entities;
// using Models;
// namespace Model2Entities
// {
// public static class Extension<Tentity>
// {
// public static TEntity ToEntity(this Book model)
// => new BookEntity
// {
// Id = model.Id,
// Title = model.Title,
// Author = model.Author,
// Isbn = model.Isbn
// };
// public static IEnumerable<TEntity> ToEntities(this IEnumerable<Book> models)
// => models.Select(m => m.ToEntity());
// public static Book ToModel(this TEntity myBookEntity)
// => new Book(myBookEntity.Id, myBookEntity.Title, myBookEntity.Author, myBookEntity.Isbn);
// public static IEnumerable<Book> ToModels(this IEnumerable<BookEntity> booksEntities)
// => booksEntities.Select(e => e.ToModel());
// }
// }

@ -1,5 +1,6 @@

using DbContextLib;
using Entities;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
@ -274,41 +275,6 @@ class Program
Console.WriteLine($"");
Console.WriteLine($"\t\t{athlete.Followers.Aggregate("", (seed, kvp) => $"{seed} [{kvp.FollowerId} ; {kvp.FollowingId} ; {kvp.StartDate.ToString("dd/MM/yyyy hh:mm:ss")}]")}");
// Console.WriteLine("\t\tFollowers :");
// Console.WriteLine("\t\t---------------------------------");
// foreach (var followers in athlete.Followers)
// {
// Console.WriteLine($"\t\t\t{followers.IdAthlete} - {followers.FirstName}, {followers.LastName}, {followers.DateOfBirth}, {followers.Sexe}, {followers.Weight}, {followers.IsCoach}");
// }
// Console.WriteLine("\t\tFollowings :");
// Console.WriteLine("\t\t---------------------------------");
// foreach (var following in athlete.Followings)
// {
// // Console.WriteLine($"\t\t{following.Followings.Aggregate("", (seed, kvp) => $"{seed} [{kvp.ArtistEntityId} ; {kvp.CreatedOn.ToString("dd/MM/yyyy hh:mm:ss")}]")}");
// Console.WriteLine($"\t\t\t{following.IdAthlete} - {following.FirstName}, {following.LastName}, {following.DateOfBirth}, {following.Sexe}, {following.Weight}, {following.IsCoach}");
// }
// using (MyDbContext db = new MyDbContext())
// {
// WriteLine("Content of database (albums) : ");
// foreach (var al in db.Albums.Include(a => a.Artists))
// {
// WriteLine($"\t{al}");
// WriteLine($"\t\t{al.AlbumArtists.Aggregate("", (seed, kvp) => $"{seed} [{kvp.ArtistEntityId} ; {kvp.CreatedOn.ToString("dd/MM/yyyy hh:mm:ss")}]")}");
// }
// WriteLine("Content of database (artists) : ");
// foreach (var ar in db.Artists)
// {
// WriteLine($"\t{ar}");
// WriteLine($"\t\t{ar.ArtistAlbums.Aggregate("", (seed, kvp) => $"{seed} [{kvp.AlbumEntityId} ; {kvp.CreatedOn.ToString("dd/MM/yyyy hh:mm:ss")}]")}");
// }
// }
}
}
}
Loading…
Cancel
Save