Entity Framework 4.1 and BLOB

I am trying to figure out how best to work with BLOBs and entities.

I am working with EF 4.1 and using POCO / DbContext

So, here is an example table:

MyTable Key int SomeFields ... ABlob (ok, it actually a Text, but whatever) 

Now, sometimes, when I select from MyTable, I want to turn on the BLOB field, but for a long time I do not.

Also, sometimes when I update MyTable, I want to update the BLOB. but a lot of time, I do not.

I can use anonymous types for the select operation, but I cannot find a way to make this work for updates at all (I cannot have 2 different classes in the same context mapped to the same table, if I try to use inheritance, I get runtime error because EF is expecting a discriminator column).

Of course, using EF does not mean that I always have to query all my BLOBs. What am I missing here?

+4
source share
2 answers

This can be done using table splitting. EF 4.1 and EF 4 .

+4
source

You can try calling the stored procedure or execute the SQL statement from your code:

 var result= context.Database.SqlQuery<string>("SELECT yourfield FROM yourtable").ToList(); 

Here is some documentation

+1
source

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


All Articles