Linq

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Linq as PDF for free.

More details

  • Words: 681
  • Pages: 4
Xquery Products.xml

Users.xml

1 <UserID>1SOAP50
2 <UserID>2BOOK40
3 <UserID>3PEN50
4 <UserID>5PENCIL50


<userId>1SunilkrishnaAssyst
<userId>2JOMYkrishnaAssyst
<userId>3ANASkrishnaAssyst
<userId>4Aneesh


Dim col As New XQueryNavigatorCollection() col.AddNavigator("tbl_users.xml", "Users") col.AddNavigator("Products.xml", "Products") Dim ds As New DataSet Dim query_outer As String Dim query_innerjoin As String Dim doc2 As New XmlDocument query_innerjoin = "for $u in document(""Users"")//Table , $p in document(""Products"")//Table " & _ "where $u/userId = $p/UserID " & _ "return
  • {$u/firstName , $p/ProductName}
  • " ''''inner join Dim expr As New XQueryExpression(query_innerjoin) Dim rawXML As String = " " & (expr.Execute(col)).ToXml() & " " ''''Outer join in hierrarichial view style query_outer = "for $p in document(""Products"")//Table " & _ "return {$p/ProductName} " & _ "{ for $u in document(""Users"")//Table " & _ " where $p/UserID =$u/userId " & _ "return <user> {$p/ProductName} {$u/firstName} }

    "

    ''''Outer join in normal style query_outer = "for $p in document(""Products"")//Table " & _ "return {$p/ProductName} " & _ "{ for $u in document(""Users"")//Table " & _ " where $p/UserID =$u/userId " & _ "return $u/firstName } " Dim expr1 As New XQueryExpression(query_outer) Dim rawXML1 As String = " " & (expr1.Execute(col)).ToXml() & " " doc2.LoadXml(rawXML1) ds.ReadXml(New XmlNodeReader(doc2)) GridData.DataSource = ds

    ADD ROW IN XML Dim ds As New DataSet strpath = "tbl_users.xml" xmlDoc.Load(strpath) Dim row As XmlNode = xmlDoc.SelectSingleNode("NewDataSet/Table[userId='2']") Dim parent As XmlNode = xmlDoc.SelectSingleNode("NewDataSet/Table[userId='2']").ParentNode row = row.CloneNode(True) '' make a copy of the node by cloning it row.SelectSingleNode("userId").InnerText = parent.ChildNodes.Count + 1 row("firstName").InnerText = TxtBox2.Text '' set the new values of the row’s fields row("lastName").InnerText = TxtBox3.Text row("companyName").InnerText = TxtBox4.Text row("userName").InnerText = TxtBox4.Text row("password").InnerText = TxtBox5.Text '' append the cloned row to the parent node parent.AppendChild(row) TxtBox1.Text = parent.ChildNodes.Count xmlDoc.Save(strpath) ds.ReadXml(strpath) GridData.DataSource = ds

    UPDATION IN XML Dim loNode As XmlNode xmlDoc.Load(strpath) Dim intId As Integer intId = GridData.Selected.Rows(0).Cells(0).Text TxtBox1.Text = intId loNode = xmlDoc.SelectSingleNode("NewDataSet/Table[userId='" & TxtBox1.Text & "']") loNode("userId").InnerText = Val(TxtBox1.Text) loNode("firstName").InnerText = TxtBox2.Text '' set the new values of the row’s fields loNode("lastName").InnerText = TxtBox3.Text loNode("companyName").InnerText = TxtBox4.Text loNode("userName").InnerText = TxtBox4.Text loNode("password").InnerText = TxtBox5.Text ' ''Dim x = xmlDoc.GetElementsByTagName("lastName") ' ''MsgBox(loNode.InnerText) ' ''For i = 1 To x.Count - 1 ' '' MsgBox(x.Item(i).InnerText) ' ''Next xmlDoc.Save(strpath) ds.ReadXml(strpath) GridData.DataSource = ds

    DELETION IN XML strpath = "tbl_users.xml" Dim ds As New DataSet With GridData Dim intId As Integer intId = .Selected.Rows(0).Cells(0).Text xmlDoc.Load(strpath) Dim row As XmlNode = xmlDoc.SelectSingleNode("NewDataSet/Table[userId='" & intId & "']") row.ParentNode.RemoveChild(row)

    xmlDoc.Save(strpath) ds.ReadXml(strpath) GridData.DataSource = ds End With

    XML ENCRYPTION Dim xmldoc As New XmlDocument() Try xmldoc.Load("D:\Aneesh k\xsl-test project\ToEncrypt.xml") 'xmldoc.Load("D:\ToQuery.xml") Catch ex As Exception Console.WriteLine(ex.Message) End Try Dim tDESkey As New TripleDESCryptoServiceProvider() Dim sElem As XmlElement = CType(xmldoc.SelectSingleNode("/NewDataSet"), XmlElement) Dim exml As EncryptedXml = New EncryptedXml(xmldoc) Dim encryptedArray As Byte() = exml.EncryptData(sElem, tDESkey, False) Dim ed As New EncryptedData() ed.Type = EncryptedXml.XmlEncElementUrl ed.EncryptionMethod = New EncryptionMethod(EncryptedXml.XmlEncTripleDESUrl) ed.CipherData = New CipherData() ed.CipherData.CipherValue = encryptedArray EncryptedXml.ReplaceElement(sElem, ed, True) xmldoc.Save("D:\Aneesh k\xsl-test project\encrypted.xml") Dim encryptedDoc As New XmlDocument() encryptedDoc.Load("D:\Aneesh k\xsl-test project\encrypted.xml") Dim encryptedElement As XmlElement = CType(encryptedDoc.GetElementsByTagName("EncryptedData")(0), XmlElement) Dim ed2 As New EncryptedData() ed2.LoadXml(encryptedElement) Dim exml2 As New EncryptedXml() Dim decryptedBilling As Byte() = exml2.DecryptData(ed2, tDESkey) MsgBox(tDESkey.ToString) exml2.ReplaceData(encryptedElement, decryptedBilling) encryptedDoc.Save("D:\Aneesh k\xsl-test project\Decrypted.xml") End Sub

    XSL New1.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">

    USER LIST

    <xsl:for-each select="NewDataSet/Table">

    firstName lastName companyName emailAddress userName password createdDate createdBy status secretQuestion secretAnswer
    <xsl:value-of select="firstName"/> <xsl:value-of select="lastName"/> <xsl:value-of select="companyName"/> <xsl:value-of select="emailAddress"/> <xsl:value-of select="userName"/> <xsl:value-of select="password"/> <xsl:value-of select="createdDate"/> <xsl:value-of select="createdBy"/> <xsl:value-of select="status"/> <xsl:value-of select="secretQuestion"/> <xsl:value-of select="secretAnswer"/>


    New.xml <userId>101aaafffxxx <emailAddress>k.kkk@ppp . . .

    Wb1.Navigate("D:\Aneesh k\xsl-test project\new.xml") “””””””Stored procedure encryption

    declare @encryptedstuff VARCHAR(100) declare @MYText VARCHAR(100) declare @decryptedstuff VARCHAR(100) SET @MYText = 'ANEESH KUZHIKKATTIL' SET @encryptedstuff = EncryptByPassPhrase('LED_PWD-2007', @MYText) SELECT @encryptedstuff SET @decryptedstuff = DecryptByPassPhrase('LED_PWD-2007', @encryptedstuff) SELECT @decryptedstuff

    Related Documents

    Linq
    October 2019 16
    Linq
    August 2019 26
    Jun-linq
    June 2020 42
    Introducing Linq
    May 2020 7
    Linq Qb
    May 2020 10