本文介绍了如何使用Entity Framework Code-First方法将double []数组存储到数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何使用Entity Framework Code-First将数组的数组存储到数据库中?对现有的代码和架构设计没有影响?How can I store an array of doubles to database using Entity Framework Code-First with no impact on the existing code and architecture design?我已经看过数据注释和流畅的API,我也考虑将双数组转换成字符串,并将该字节存储在数据库的自己的列中。I've looked at Data Annotation and Fluent API, I've also considered converting the double array to a string of bytes and store that byte to the database in it own column.我无法访问 public double [] Data {get;组; } 属性与Fluent API,然后我得到的错误消息是:I cannot access the public double[] Data { get; set; } property with Fluent API, the error message I then get is:存储数据的类已成功存储在数据库中,并与此类的关系。我只是缺少数据列。The class where Data is stored is successfully stored in the database, and the relationships to this class. I'm only missing the Data column.推荐答案感谢大家的投入,由于您的帮助,我能够追踪解决这个问题的最佳方法。哪个是:Thank you all for your inputs, due to your help I was able to track down the best way to solve this. Which is: public string InternalData { get; set; } public double[] Data { get { return Array.ConvertAll(InternalData.Split(';'), Double.Parse); } set { _data = value; InternalData = String.Join(";", _data.Select(p => p.ToString()).ToArray()); } }感谢这些stackoverflow帖子: String to Doubles数组和 将数组组合成字符串Thanks to these stackoverflow posts:String to Doubles array andArray of Doubles to a String 这篇关于如何使用Entity Framework Code-First方法将double []数组存储到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 18:28