开发者

How to generically read text files and save into databases without evaluating data type?

I need to write a C# program for reading any flat text files and, for every line, parses using a regex expression previously saved in a configuration file, which separates the line in several fields that are stored in a List object where each element is a field. Then, let each field be saved in the respective fields previously created within a database table and so on for each line.

At this point, everything is seen as that data is orchestrated without interference, as a pipe that runs from the text file to the database. However, I face the difficulty where some of the fields can represent dates/hours in different formats, bool, double etc. For these few cases, I will need to modify my program and make some sort of if-statements that would minimally generate an overhead in processing times.

The question is to know whether there is any methodology or technique within the开发者_运维百科 C# that, despite the special cases mentioned, it allows me to record the data in the database without the overhead of previous evaluations to establish the data type?

Thank you.


Why not just write all of the data from the text file into a database whose fields are all strings (varchar, text, etc). At some point you must need to query the database to use the values, and that's when you can convert from the strings into their respective data types.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜