c# - Convert anonymous type to array or arraylist. Can it be done -
Trying to retrieve data using the Linux from the database. I want to use anonymous forms and convert to Ilist, Array, ArrayList or archive. Data is used in third party objects that accept Ilist, arraylist or archive.
I can not seem to do this work. I get the following error, "Sequence operators are not supported to use 'system.String'" "
(var db = new dbDataContext ()) {var query = e Select db.people in db.people new {calculation = e.lastname.count ()} array test; test = query.ToArray ();}
There is nothing to convert results to array lists, or to anonymity type. Here is another version of your code that will fail:
Using (var db = new dbDataContext ()) {Var query = db.people.Select (x = & gt; x.ListName.Count ()); Foreach (int x in query) {Console.WriteLine (x);}}
< P> It will still fail in the same way - because it is the translation of this bit: x => in SLAL. / Code> is causing the problem.
Change it to:
x => X.ListName.Length
And I suspect that you will work it. Note that this is not really a C # issue - it's just LINQ for SQL's translation capabilities.
I would suggest that you do not not use an anonymous type here - it is futile. Maybe this is not your whole code, but in general if you create an unknown type with a single member, then ask yourself if you are really doing any good work.
Comments
Post a Comment