How to save an image in a database?

I am working on Linq To Sql, WPF, and I have a database, now I need to save some image in the database, but I do not know what the correct data type is for saving the image database (this database will connect from 10 users at the same time ) Can you show me the right way to overcome this step? If I’m not mistaken, don’t save photos in the database, but if you can advise me on the best method, I will apply it. Thanks so much for your time.

Yours faithfully

+3
source share
5 answers

'varbinary (MAX)' 'image'. Linq2Sql , . [].

myObject.Image = new Binary(imageByteArray);
+5

blob, , , , byte []. , .

+3

varbinary (max) , max- , [] .

+1

, , , , .

, SQL-, , db. , .

, .

:

- :

public partial class LinqClass
{
    public string ImagePath { get; set; }

    public System.Drawing.Image Picture
    {
        get
        {
            return System.Drawing.Image.FromFile(ImagePath);
        }
    }
}

ImagePath - db, . (- File.Save(ImagePath) .., .

+1

I never did this with Linq, but we used the b64 conversion for the image and then the clob data type. Then change the b64 value when you want to view the image.

0
source

Source: https://habr.com/ru/post/1709117/


All Articles