Just FYI, you never add a new one HouseAnnouncementto your list, and your loop will never run for the last line, but I assume that these are errors in the example, and not in your actual code.
You can do something like this:
return adapter.GetData().Rows.Cast<DataRow>().Select(row =>
new HouseAnnouncement()
{
Area = Convert.ToSingle(row["powierzchnia"]),
City = (string)row["miasto"],
}).ToList();
I usually read for brevity, but I feel that it is pretty readable.
, DataTable table.powierzchniaColumn , , , ( , , ).
, , :
using (var table = adapter.GetData())
{
return table.Rows.Cast<DataRow>().Select(row =>
new HouseAnnouncement()
{
Area = Convert.ToSingle(row[table.powierzchniaColumn]),
City = (string)row[table.miastoColumn],
}).ToList();
}
, , .