So what I'm trying to do is to save a byte[] into my database. If the byte is to long to be send to the database I whould like to split it into two bytes of half the size. However I'm doing something wrong, because when I check that the splittet bytes combined is equal to the original byte is ain't.
My code looks like this:
    public File Add(File item)
    {
        try
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            db.Entry(item).State = EntityState.Added;
            db.SaveChanges();
        }
        catch
        {
            File firstHalf = item;
            File lastHalf = item;
            firstHalf.@byte = item.@byte.Take(item.@byte.Length / 2).ToArray();
            lastHalf.@byte = item.@byte.Skip(item.@byte.Length / 2).ToArray();
            byte[] rv = new byte[firstHalf.@byte.Length + firstHalf.@byte.Length];
            System.Buffer.BlockCopy(firstHalf.@byte, 0, rv, 0, firstHalf.@byte.Length);
            System.Buffer.BlockCopy(lastHalf.@byte, 0, rv, firstHalf.@byte.Length, lastHalf.@byte.Length);
            if(rv == item.@byte)
            {
                Add(firstHalf);
                Add(lastHalf);
            }
        }
        return item;
    }
Edit
public partial class File
{
    public int C_id { get; set; }
    public string name { get; set; }
    public byte[] @byte { get; set; }
    public int file_id { get; set; }
    public int fk_folder { get; set; }
    public int fk_profile { get; set; }
}
 
     
    