如何将每条记录从查询结果转换为数组 [英] How can I convert each record from query result to array
问题描述
如何将每条记录从查询结果转换为数组
抱歉,因为我是C#的新手,我想转换每条记录从DATABASE检索到arraylist
我的代码如下:
How can I convert each record from query result to array
Sorry as I am new to C# I want to convert each record retrieved from the DATABASE to arraylist
my code is as follow:
var reservation = from x in db.resrvation where x.date=Calendar1.SelectedDate select x;
//here i want to get each record in reservation and convert it to array so i can gets specific data eg clint name
按预订检索的集合包括否。记录中的每一个都有clintName,Phone,ReservationDate等属性。我想为每条记录制作一个arraylist。
实际上我正在尝试使用这个arraylist来填充数据表原始。
我希望我达到了这一点
谢谢
the collection retrieved by reservation include no. of records each of them have properties such as clintName,Phone,ReservationDate,..etc I want to make an arraylist for each record .
actually I am trying to use this arraylist to fill datatable raw.
I hope I reached the point
Thanks
推荐答案
你好亲爱的朋友。你可以使用它:
Hello dear friend.you can use this :
List<object> Items = new List<objects>();
foreach(object item in reservation)
Items.add(item);
</objects></object>
您可以为表格的数据建立一个模型,您可以投放< item>的每个项目。列入该模型,如
You can make a model for your table's data which you can cast each items of <item> list into that model like
MyModel myModel = Items<n> as MyModel;</n>
您可以像这样使用Array而不是List:
You can use Array instead of List like this :
object[] Items = new object()[int.Max];
我希望它可以帮到你。
I hope it can help you.
这篇关于如何将每条记录从查询结果转换为数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!