我必须使用什么属性才能使用 CsvReader 读取这些日期字段?
What attribute must I use to read in these date fields using CsvReader?
我的 CSV 文件有一个名为 Date
的字段。此列中的值的类型为 dd/mm/yyyy
.
例如:
08/01/2022
目前我在 CsvReader
class 中将其映射到 string
:
public class CLMExplorerHistory
{
[Name("Date")]
public string Date { get; set; }
}
我已经测试读取我的 CSV 文件(显然有更多信息列):
public void Test2()
{
string strPath = "d:\Import CLM\Calendar Simon.csv";
if (!File.Exists(strPath))
return;
try
{
using (var reader = new StreamReader(strPath))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
var records = csv.GetRecords<CLMExplorerHistory>();
foreach (var record in records)
{
SimpleLog.Log(record.Date);
}
}
}
catch (System.Exception ex)
{
SimpleLog.Log(ex);
}
}
我检查了日志,一切正常:
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>01/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>08/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>15/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>22/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>29/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>05/04/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>12/04/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>19/04/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>26/04/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>03/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>10/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>17/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>24/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>31/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>07/06/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>14/06/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>21/06/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>28/06/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>05/07/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>12/07/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>19/07/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>26/07/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>02/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>09/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>16/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>23/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>30/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>06/09/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>13/09/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>20/09/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>27/09/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>04/10/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>11/10/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>18/10/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>25/10/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>01/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>08/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>15/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>22/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>29/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>06/12/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>13/12/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>20/12/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>27/12/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>03/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>10/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>17/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>24/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>31/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>07/02/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>14/02/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>21/02/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>28/02/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>07/03/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>14/03/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>21/03/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>28/03/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>04/04/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>18/04/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>25/04/2022</Message>
</LogEntry>
我可以向我的 属性 添加什么 属性 以便它可以成为 DateTime
对象?我不想使用 map,而是使用属性限定符。
相当确定
[Format("dd/MM/yyyy")]
[Name("Date")]
public DateTime Date { get; set; }
..但是如果我记错了请告诉我,这完全是胡说八道
从技术上讲,如果 prop 的名称相同,则 Name 属性是不必要的,但我确信给 属性 一个更具描述性的名称在待办事项列表中名列前茅,因此我将其保留下来更容易
我的 CSV 文件有一个名为 Date
的字段。此列中的值的类型为 dd/mm/yyyy
.
例如:
08/01/2022
目前我在 CsvReader
class 中将其映射到 string
:
public class CLMExplorerHistory
{
[Name("Date")]
public string Date { get; set; }
}
我已经测试读取我的 CSV 文件(显然有更多信息列):
public void Test2()
{
string strPath = "d:\Import CLM\Calendar Simon.csv";
if (!File.Exists(strPath))
return;
try
{
using (var reader = new StreamReader(strPath))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
var records = csv.GetRecords<CLMExplorerHistory>();
foreach (var record in records)
{
SimpleLog.Log(record.Date);
}
}
}
catch (System.Exception ex)
{
SimpleLog.Log(ex);
}
}
我检查了日志,一切正常:
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>01/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>08/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>15/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>22/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>29/03/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>05/04/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>12/04/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>19/04/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>26/04/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>03/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>10/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>17/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>24/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>31/05/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>07/06/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>14/06/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>21/06/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>28/06/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>05/07/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>12/07/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>19/07/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>26/07/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>02/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>09/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>16/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>23/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>30/08/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>06/09/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>13/09/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>20/09/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>27/09/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>04/10/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>11/10/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>18/10/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>25/10/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>01/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>08/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>15/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>22/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>29/11/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>06/12/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>13/12/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>20/12/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>27/12/2021</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>03/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>10/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>17/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>24/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>31/01/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>07/02/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>14/02/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>21/02/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>28/02/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>07/03/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>14/03/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>21/03/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>28/03/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>04/04/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>18/04/2022</Message>
</LogEntry>
<LogEntry Date="2022-01-08 20:02:08" Severity="Info" Source="MSAToolsLibrary.MSAToolsLibraryClass.Test2" ThreadId="1">
<Message>25/04/2022</Message>
</LogEntry>
我可以向我的 属性 添加什么 属性 以便它可以成为 DateTime
对象?我不想使用 map,而是使用属性限定符。
相当确定
[Format("dd/MM/yyyy")]
[Name("Date")]
public DateTime Date { get; set; }
..但是如果我记错了请告诉我,这完全是胡说八道
从技术上讲,如果 prop 的名称相同,则 Name 属性是不必要的,但我确信给 属性 一个更具描述性的名称在待办事项列表中名列前茅,因此我将其保留下来更容易