This is more a question regarding generics than subsonic:
Imagine if have the following code:
List<int> result =
DB.Select(Product.Columns.Id)
.From<Product>()
.ExecuteTypedList<int>();
That works great and returns a generic list with the ids from my Product table.
But if I want to get a list of the ProductName:
List<String> result =
DB.Select(Product.Columns.ProductName)
.From<Product>()
.ExecuteTypedList<String>();
it throws a compiler message (translated from german):
"string" has to be a non-abstract type with a public Constructor without parameter, in order to be used as a generic type or in the generic method "SubSonic.SqlQuery.ExecuteTypedList()" as param "T".
cause: String has no empty contructor:
int i = new int; // works
String s = new String; // compiler error: "string" does not contain a constructor that takes '0' argument
If I use a , but is there a more elegant way, where I can use List<Object>
instead it worksList<String>
?
Update: List<Object>
does not work. I indeed get a list of objects but that seem to be "empty" object that doesn't contain my ProductNames ( object.ToString() returns {Object}
)