Click here to Skip to main content
15,179,684 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have read about generic list and dataset ,i know generic list is type-safe and dataset is not ,but we can make dataset also type-safe.I have read the returning dataset is bad ,it will reduce performance ,but how ??

we are getting data in the dataset and through foreach storing it in generic list
so how generic list increse performance and dataset will not,

when should i use return dataset and when should i return genric list.

Please help

public List<AssetCardDTO> GetAssetTagNo()
         DataSet dsUserFav = new DataSet();
         AssetCardDTO objAssetCardDto;
         List<AssetCardDTO> objAssetCardDtoList = new List<AssetCardDTO>();
             Database db = DatabaseFactory.CreateDatabase("testConnectionString5");
             DbCommand myCommand = db.GetStoredProcCommand("usp_getAssetTagNo");
             dsUserFav = db.ExecuteDataSet(myCommand);

             foreach (DataRow dr in dsUserFav.Tables[0].Rows)
                 objAssetCardDto = new AssetCardDTO();

                 objAssetCardDto.TextFeild = dr["Textfield"].ToString();
                 objAssetCardDto.ValueFeild = dr["Valuefield"].ToString();

             return objAssetCardDtoList;
         catch (Exception ex)
             string message = ex.Message.ToString();
             return null;            

1 solution

This msdn article may answer your doubts.
There is no definitive solution, the correct answer is always: "it depends".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900