I have a class with several submembers, i.e.
class structA
{
double a;
double b;
structB c;
}
class structB
{
double d;
double e;
}
What is the best way to persist this class to a database, in order to store large amounts of data, e.g. streaming stock data? I want something simpl开发者_如何学JAVAe, preferably with some form of LINQ so I can query the data at a later date.
There's so many methods that I'm just not sure which way to turn, i.e. Do I LINQ to SQL? LINQ to Entities? LINW to CSV? LINQ to objects? Microsoft SQL? MySQL? PostgreSQL? InfiniDB? MongoDB?
If you are asking how can I write data quickly to a database I would make 2 points.
Firstly assuming you have chosen your underlying database and programming model (let's say you choose .NET and MS-SQL - since you mention LINQ I assume you're in a .NET world and so this is the most natural choice) then just use the lowest level write technique available. In the .NET case use the ADO.NET API directly instead of going via LINQ.
Second point, if you need really fast writes you can buffer the data in memory and then construct a batch write statement, and again execute this via the ADO.NET API.
I don't think it matters particularly what database and programming model you go for, I'm not aware of any that is particularly geared to speedy database inserts, I would expect it's far more dependant on the way you implement the solution.
To address your other concern.. just because you don't use LINQ to insert data it doesn't mean you can't use it to read data, and obviously using LINQ is not a prerequisite to enable you to read the data at a later date.
Finally - if you really want to use LINQ then try using LINQ - it might be that it's fast enough. It depends on exactly how fast your stream of data is - only testing can tell.
精彩评论