小编Nic*_*ico的帖子

C#如何将List <object []>转换为List <customClass>

这是我的代码.可以在Linqpad中运行.

void Main(){

   List<Object> listobj=new List<object>{
   new object[]{"A01001","sucess","on"},
   new object[]{"A01002","fail","off"}};
   listobj.Dump();

   var second = listobj.Cast<RowItem>();
   second.Dump();
}

public class RowItem {
   public string GOODS_ID { get; set; }
   public string AUDIT_STATUS { get; set; }
   public string APPLY_STATUS { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我想转换List<object>List<RowItem>,但当我使用cast方法时,它返回一个错误cannot convert type 'System.Object[]' to class RowItem

这是可能的,还是有另一种方法来实现这一目标?

谢谢.

c# linq

2
推荐指数
1
解决办法
1536
查看次数

Remove u' from a mongodb list

I have a script and I want to remove u'domain' and u from the list

from pymongo import MongoClient


client = MongoClient()
db = client.domains
collection = db.domain
find_document = collection.find({},{'domain': 1, '_id':0})

data = list(find_document.limit(2))

{myIds.push(myDoc.domain.str)})
print (data)
Run Code Online (Sandbox Code Playgroud)

The result is :

[{u'domain': u'allegacyhsa.org'}, {u'domain': u'americanhelpinghands.org'}]
Run Code Online (Sandbox Code Playgroud)

I want to print only the domain like :

['allegacyhsa.org','americanhelpinghands.org']
Run Code Online (Sandbox Code Playgroud)

Without u and {

Thank you in advance for your answer.

python mongodb

0
推荐指数
1
解决办法
1407
查看次数

标签 统计

c# ×1

linq ×1

mongodb ×1

python ×1