diff --git a/Example/UsingTest/Script/EGSaveTest.cs b/Example/UsingTest/Script/EGSaveTest.cs index 5594152..f1135ad 100644 --- a/Example/UsingTest/Script/EGSaveTest.cs +++ b/Example/UsingTest/Script/EGSaveTest.cs @@ -25,12 +25,25 @@ namespace EGFramework.Examples.Test{ csvSave.InitSaveFile("SaveData/TestCsv.csv"); // Customer testData = csvSave.GetData("",1); // GD.Print("Name = "+testData.Name +" || ID = "+testData.Id); - Customer testData = new Customer(){ - Id = 1008, - Name = "AddDataDefault", - IsActive = true - }; - csvSave.SetData("",testData,2); + // Customer testData = new Customer(){ + // Id = 1008, + // Name = "AddDataDefault", + // IsActive = true + // }; + // csvSave.SetData("",testData,2) + + IEnumerable allResult = csvSave.GetAll(""); + GD.Print("Get result " + allResult.Count()); + foreach(Customer customer in allResult){ + GD.Print(customer.Id +"|" + customer.Name); + } + + // System.Linq.Expressions.Expression> expr = i => i.Id < 5; + // IEnumerable linqResult = csvSave.FindData("",expr); + // GD.Print("Find result " + linqResult.Count()); + // foreach(Customer customer in linqResult){ + // GD.Print(customer.Name); + // } // GD.Print(typeof(Customer)); // Type type = typeof(Customer); diff --git a/addons/EGFramework/Module/SaveTools/EGCsvSave.cs b/addons/EGFramework/Module/SaveTools/EGCsvSave.cs index 0538205..c7a7d6c 100644 --- a/addons/EGFramework/Module/SaveTools/EGCsvSave.cs +++ b/addons/EGFramework/Module/SaveTools/EGCsvSave.cs @@ -165,19 +165,19 @@ namespace EGFramework // throw new NotImplementedException(); List DataList = new List(); for (int dataID = 0; dataID < CsvDataBlock.Count(); dataID++){ + TData data = new TData(); foreach(PropertyInfo property in typeof(TData).GetProperties()){ CsvParamAttribute csvParam = property.GetCustomAttribute(); if(csvParam != null && CsvDataHeader.ContainsKey(csvParam._name)){ string valueStr = CsvDataBlock[dataID][CsvDataHeader[csvParam._name]]; - TData data = new TData(); if(property.PropertyType==typeof(string)){ property.SetValue(data,valueStr); }else{ property.SetValue(data,Convert.ChangeType(valueStr,property.PropertyType)); } - DataList.Add(data); } } + DataList.Add(data); } TypeDataContainer.Register(DataList); return DataList;