【发布时间】:2013-06-07 20:13:15
【问题描述】:
以下是我使用 linq 登录数据库的内容,然后我使用 C# 表达式收集我想要的数据。我想做的下一件事是将这些数据转换为 XML 任何想法?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Data;
namespace VcacManagementTools.BuildProfiles
{
public static class BuildProfileTools
{
public static ICollection<string> GetExistingBuildProfileNames(string repositoryHostname,
string repositoryUsername,
string repositoryPassword)
{
var url = string.Format("https://{0}/repository/data/ManagementModelEntiti.svc", repositoryHostname);
var managementModelClient = new DynamicOps.ManagementModel.ManagementModelEntities(new Uri(url))
{
Credentials = new NetworkCredential(repositoryUsername, repositoryPassword)
};
return managementModelClient
.GlobalProfiles
.Select(gp => gp.ProfileName)
.ToList();
我收到的输出是一个值列表
【问题讨论】:
-
如果你熟悉 LINQ,何不试试 LINQ to XML,那里有很多很棒的工具,语法与其他 LINQ 功能相似。
-
您是否在使用您在代码中声明的 DataTable?
-
@YuriyGalanter 抱歉,这是一个错误
-
@Evanlewis 抱歉,我是 C# 新手,对 LINQ 不太熟悉,但您知道有教程的网站吗?
-
这里有很好的教程,您的需要请参阅第 2 节(或问题 9)。 LINQ to XML Tutorial