Everywhere I ask this question about C#, I'm only getting answers for images and files. I want to store an object as BLOB, not an image, into the database from one asp.net application, and retrieve it from another application.
Let's say I have a model Person
:
public class Person
{
public int userID { set; get; }
public string userName { get; set; }
public string lastName { get; set; }
public string firstName { get; set; }
public string email { get; set; }
public List<int> someAttr { get; set; }
public List<int> otherAttr { get; set; }
public List<SomeModel> modelAttr { get; set; }
public List<AnotherModel> modelAttr2 { get; set; }
}
This model not only has regular datatype values, but some List(arrays) as well as other specific model type data (SomeModel
and AnotherModel
). For this reason I need to store this model's object into the database and retrieve it from another application, as the session variables are lost while navigation to and fro between different asp.net applications.
Now my object would be:
Person p1 = *Retrieve data from database, and store it to p1*
I'm trying to store p1 in the database, with all its values intact so that when I retrieve it from my second asp.net mvc application, I can use it like p1.userName
, p1.email
, and then the lists within a loop like:
for(int i=0; i<p1.someAttr.Count(); i++)
{
*use i.someAttr[i] in some way*
}
I have found various resources to do this, but with image files. They don't match with my scenario so I'm posting this question.
http://www.c-sharpcorner.com/uploadfile/Ashush/working-with-binary-large-objects-blobs/ http://www.aspsnippets.com/Articles/Read-and-Write-BLOB-Data-to-SQL-Server-database-using-C-and-VBNet.aspx
Thank you.