Gax
Gax
CC#
Created by KAI on 12/31/2024 in #help
LEARNING C#
Trial and a lot of errors
37 replies
CC#
Created by KAI on 12/31/2024 in #help
LEARNING C#
Try to do something, if you don't know then search about what you don't know For example, I want to get weather data from openweatherapi but idk how to do requests, I then search how to do an http request and then try to continue from there
37 replies
CC#
Created by KAI on 12/31/2024 in #help
LEARNING C#
I'd recommend getting started on C# itself with some very small and basic $projects and then jumping into unity for that exact reason, you won't know exactly what youre doing However if you want to write code and implement in unity all you have to do is create a new MonoBehaviour script from unity (or manually if you know how), then attach it to a game object as a component
37 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
at this point im considering rewriting it from scratch and see if a random change i didn't consider does it
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
sadly no
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
That is not the issue here though, but I get what you mean
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
its alright, thanks for trying anyways :)
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
i updated it to the proper one
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
had some code that i was testing
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
wait first one is wrong
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
public class PersonRepository : IRepository<Person>
{
private readonly MeminisseDbContext _context;

public PersonRepository(MeminisseDbContext context)
{
_context = context;
}

public async Task AddAsync(Person entity)
{
await _context.People.AddAsync(entity);
await _context.SaveChangesAsync();
}

public async Task AddRangeAsync(List<Person> entities)
{
await _context.People.AddRangeAsync(entities);
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(Person entity)
{
_context.People.Remove(entity);
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(Guid id)
{
var entity = await _context.People.FindAsync(id);
if (entity != null)
{
_context.People.Remove(entity);
await _context.SaveChangesAsync();
}
}

public IQueryable<Person> Get()
{
return _context.People.AsQueryable();
}

public async Task<List<Person>> GetAllAsync()
{
return await _context.People.ToListAsync();
}

public async Task UpdateAsync(Person entity)
{
_context.People.Update(entity);
await _context.SaveChangesAsync();
}
}
public class PersonRepository : IRepository<Person>
{
private readonly MeminisseDbContext _context;

public PersonRepository(MeminisseDbContext context)
{
_context = context;
}

public async Task AddAsync(Person entity)
{
await _context.People.AddAsync(entity);
await _context.SaveChangesAsync();
}

public async Task AddRangeAsync(List<Person> entities)
{
await _context.People.AddRangeAsync(entities);
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(Person entity)
{
_context.People.Remove(entity);
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(Guid id)
{
var entity = await _context.People.FindAsync(id);
if (entity != null)
{
_context.People.Remove(entity);
await _context.SaveChangesAsync();
}
}

public IQueryable<Person> Get()
{
return _context.People.AsQueryable();
}

public async Task<List<Person>> GetAllAsync()
{
return await _context.People.ToListAsync();
}

public async Task UpdateAsync(Person entity)
{
_context.People.Update(entity);
await _context.SaveChangesAsync();
}
}
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
public class MemoryRepository : IRepository<Memory>
{
private readonly MeminisseDbContext _context;

public MemoryRepository(MeminisseDbContext context)
{
_context = context;
}

public async Task AddAsync(Memory entity)
{
await _context.Memories.AddAsync(entity);
await _context.SaveChangesAsync();
}

public async Task AddRangeAsync(List<Memory> entities)
{
await _context.Memories.AddRangeAsync(entities);
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(Memory entity)
{
_context.Memories.Remove(entity);
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(Guid id)
{
var entity = await _context.Memories.FindAsync(id);
if (entity != null)
{
_context.Memories.Remove(entity);
await _context.SaveChangesAsync();
}
}

public IQueryable<Memory> Get()
{
return _context.Memories.AsQueryable();
}

public async Task<List<Memory>> GetAllAsync()
{
return await _context.Memories.ToListAsync();
}

public async Task UpdateAsync(Memory entity)
{
_context.Memories.Update(entity);
await _context.SaveChangesAsync();
}
}
public class MemoryRepository : IRepository<Memory>
{
private readonly MeminisseDbContext _context;

public MemoryRepository(MeminisseDbContext context)
{
_context = context;
}

public async Task AddAsync(Memory entity)
{
await _context.Memories.AddAsync(entity);
await _context.SaveChangesAsync();
}

public async Task AddRangeAsync(List<Memory> entities)
{
await _context.Memories.AddRangeAsync(entities);
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(Memory entity)
{
_context.Memories.Remove(entity);
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(Guid id)
{
var entity = await _context.Memories.FindAsync(id);
if (entity != null)
{
_context.Memories.Remove(entity);
await _context.SaveChangesAsync();
}
}

public IQueryable<Memory> Get()
{
return _context.Memories.AsQueryable();
}

public async Task<List<Memory>> GetAllAsync()
{
return await _context.Memories.ToListAsync();
}

public async Task UpdateAsync(Memory entity)
{
_context.Memories.Update(entity);
await _context.SaveChangesAsync();
}
}
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
what bugs me is that whatever i do with Memory works perfectly with Person, they call the "same" methods (from their respective tables), have pretty much the same implementation and only one of them has this issue
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
same exception
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
FindAsync
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
i do
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
it is, yes
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
yep
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
the memory, person and memoryperson are all saved in the database
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
i thought about that but everything is being added to the database correctly
46 replies