本文整理汇总了C#中System.Data.SqlTypes.SqlXml类的典型用法代码示例。如果您正苦于以下问题:C# SqlXml类的具体用法?C# SqlXml怎么用?C# SqlXml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlXml类属于System.Data.SqlTypes命名空间,在下文中一共展示了SqlXml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetCapacity
override public void SetCapacity(int capacity) {
SqlXml[] newValues = new SqlXml[capacity];
if (null != values) {
Array.Copy(values, 0, newValues, 0, Math.Min(capacity, values.Length));
}
values = newValues;
}
示例2: XMLRecordNewAttribute
public static String XMLRecordNewAttribute(SqlXml DataXml, String ATag, String AAttributeName, String AAttributeValue)
{
if (DataXml.IsNull) return null;
if(String.IsNullOrWhiteSpace(ATag))
throw new System.Exception("Parameter @Tag can't be null or empty");
if(String.IsNullOrWhiteSpace(AAttributeName))
throw new System.Exception("Parameter @AttributeName can't be null or empty");
if(AAttributeValue == null) //return DataXml.Value;
throw new System.Exception("Parameter @AttributeValue can't be null");
XmlDocument UpdateDoc = new XmlDocument();
XmlNode UpdateRoot = UpdateDoc.CreateElement("RECORDS");
UpdateRoot.InnerXml = DataXml.Value;
for(int I = 0; I < UpdateRoot.ChildNodes.Count; I++)
{
XmlNode UpdateNode = UpdateRoot.ChildNodes[I];
if(UpdateNode.LocalName == ATag)
{
XmlAttribute Attribute = UpdateDoc.CreateAttribute(AAttributeName);
Attribute.Value = AAttributeValue;
UpdateNode.Attributes.Append(Attribute);
}
}
return UpdateRoot.ChildNodes.Count == 0 ? null : UpdateRoot.InnerXml;
}
示例3: ExecScript
public static SqlXml ExecScript(SqlString Sql, SqlXml Options, SqlXml Input)
{
var XOutput = new XDocument(
new XElement("root",
new XElement("content")));
try
{
using (var q = new SqlCommand())
{
q.Connection = new SqlConnection("context connection=true");
q.CommandType = CommandType.Text;
q.CommandText = Sql.Value;
q.InitOptions(Options.Value);
q.Parameters.SetInput(Input.Value);
q.Connection.Open();
q.ExecuteNonQuery();
XOutput.Root.Add(q.Parameters.GetOutput());
q.Connection.Close();
}
}
catch (Exception ex)
{
XOutput.Root.Add(ex.ExceptionSerialize());
}
return new SqlXml(XOutput.CreateReader());
}
示例4: DefaultStoreSchemaInfo
/// <summary>
/// Constructs the storage representation from client side objects.
/// </summary>
/// <param name="name">Schema info name.</param>
/// <param name="shardingSchemaInfo">Schema info represented in XML.</param>
internal DefaultStoreSchemaInfo(
string name,
SqlXml shardingSchemaInfo)
{
this.Name = name;
this.ShardingSchemaInfo = shardingSchemaInfo;
}
示例5: Constructor2_Stream_Empty
[Fact] // .ctor (Stream)
public void Constructor2_Stream_Empty()
{
MemoryStream ms = new MemoryStream();
SqlXml xmlSql = new SqlXml(ms);
Assert.False(xmlSql.IsNull);
Assert.Equal(string.Empty, xmlSql.Value);
}
示例6: ExecQuery
public static SqlXml ExecQuery(SqlString Sql, SqlXml Options, SqlXml Input)
{
var XOutput = new XDocument(new XElement("root"));
try
{
using (var q = new SqlCommand())
{
q.Connection = new SqlConnection("context connection=true");
q.CommandType = CommandType.Text;
q.CommandText = Sql.Value;
q.InitOptions(Options.Value);
q.Parameters.SetInput(Input.Value);
q.Connection.Open();
var Result = q.ExecuteXmlReader();
if (Result.Read())
XOutput.Root.Element("content").Add(
XElement.Load(Result, LoadOptions.None));
q.Connection.Close();
}
}
catch (Exception ex)
{
XOutput.Root.Add(ex.ExceptionSerialize());
}
return new SqlXml(XOutput.CreateReader());
}
示例7: GetXml
/// <summary>
/// Return XML for an array of items
/// </summary>
/// <param name="List">List of items</param>
/// <param name="ListName">Name of the list</param>
/// <param name="ItemName">Name of the item in the list.</param>
/// <returns></returns>
public static SqlXml GetXml(IEnumerable List, string ListName, string ItemName)
{
//We don't use 'using' or dispose or close the stream,
//since it leaves in the return variable
MemoryStream stream = new MemoryStream();
SqlXml Result = null;
try
{
using (XmlWriter writer = XmlWriter.Create(stream))
{
writer.WriteStartElement(ListName);
foreach (object obj in List)
{
writer.WriteElementString(ItemName, obj.ToString());
}
writer.WriteEndElement();
Result = new SqlXml(stream);
}
}
catch (Exception ex)
{
throw (ex);
}
finally
{
}
return Result;
}
示例8: ParamDateTimeTemp
public static SqlDateTime ParamDateTimeTemp(SqlXml Xml, SqlString Name)
{
String ValueType;
String Value = GetValueFromXMLAttribute(Xml, Name, out ValueType);
if (Value == null) return new SqlDateTime();
SqlDateTime Result;
try
{
Result = new SqlDateTime(XmlConvert.ToDateTime(Value, XmlDateTimeSerializationMode.RoundtripKind));
}
catch (Exception Error)
{
throw new System.Exception("Error convert Param = \"" + Name.Value.ToString() + "\" Value = \"" + Value.ToString() + "\" to DateTime: " + Error.Message);
}
if (ValueType != null && ValueType != "")
{
// year, month, day, hour, minute, second
switch (ValueType)
{
case "1": return Result.Value.Date.AddDays(1);
default: return Result;
}
}
return Result;
}
示例9: SqlTriggerContext
internal SqlTriggerContext (TriggerAction triggerAction, bool[] columnsUpdated,
SqlXml eventData)
{
this.triggerAction = triggerAction;
this.columnsUpdated = columnsUpdated;
this.eventData = eventData;
}
示例10: XMLRecordInnerXml
public static String XMLRecordInnerXml(SqlXml AXml, String ATag)
{
XmlReader LReader = AXml.CreateReader();
LReader.Read();
while(!LReader.EOF)
{
if(LReader.NodeType == XmlNodeType.Element)
{
if (LReader.Name == ATag)
{
String LInnerXml = LReader.ReadInnerXml();
if (String.IsNullOrWhiteSpace(LInnerXml))
return null;
else
return LInnerXml;
}
else
{
if (!LReader.IsEmptyElement)
LReader.Skip();
else
LReader.Read();
}
}
else
LReader.Read();
}
return null;
}
示例11: Constructor2_Stream_ASCII
public void Constructor2_Stream_ASCII ()
{
string xmlStr = "<Employee><FirstName>Varadhan</FirstName><LastName>Veerapuram</LastName></Employee>";
MemoryStream stream = new MemoryStream (Encoding.ASCII.GetBytes (xmlStr));
SqlXml xmlSql = new SqlXml (stream);
Assert.IsFalse (xmlSql.IsNull, "#1");
Assert.AreEqual (xmlStr, xmlSql.Value, "#2");
}
示例12: CreateActivity
public static void CreateActivity(SqlString url, SqlString username, SqlString password, SqlString token, SqlString employeeId, SqlXml messageBlob)
{
IChatterService service = new ChatterService(url.Value);
service.AllowUntrustedConnection();
service.Login(username.Value, password.Value, token.Value);
CreateProfileActivity(service, employeeId.Value, messageBlob.Value);
}
示例13: Constructor2_Stream_Unicode
[Fact] // .ctor (Stream)
//[Category ("NotDotNet")] // Name cannot begin with the '.' character, hexadecimal value 0x00. Line 1, position 2
public void Constructor2_Stream_Unicode()
{
string xmlStr = "<Employee><FirstName>Varadhan</FirstName><LastName>Veerapuram</LastName></Employee>";
MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(xmlStr));
SqlXml xmlSql = new SqlXml(stream);
Assert.False(xmlSql.IsNull);
Assert.Equal(xmlStr, xmlSql.Value);
}
示例14: SaveXMLTofile
public static void SaveXMLTofile(SqlXml XMLData, String DestFile, Boolean Append)
{
StreamWriter writer = new StreamWriter(DestFile, Append, System.Text.Encoding.UTF8);
writer.Write(@"<?xml version=""1.0"" encoding=""utf-8"" ?>");
writer.Write(XMLData.Value);
writer.Close();
SqlContext.Pipe.Send(String.Format("XML text successfully saved to file '{0}'", DestFile));
}
示例15: TestCreateActivityWithMissingBody
public void TestCreateActivityWithMissingBody()
{
string xml =
"<activity xmlns=\"http://ns.opensocial.org/2008/opensocial\"><postedTime>1310597396000</postedTime><title>Edited their narrative</title></activity>";
var xmlReader = XmlTextReader.Create(new System.IO.StringReader(xml));
SqlXml messageBlob = new SqlXml(xmlReader);
//ChatterSqlProcedures.CreateActivity(_url, _username, _password, _token, _employeeId, messageBlob, _pmid, _title, _body);
}