Asp.net & Sql server fundas with Rajat Jaiswal

November 14, 2009

Some useful Terminology (acronyms)

Filed under: Ado.net Data Services, Asp.net, Astoria, JUERY, LINQ, MVC, WCF, WPF, XML, ajax — indiandotnet @ 5:22 am
Tags: , , , ,

Hello friends,
Cheers!
Here I am with some useful terminology and these acronyms are generally used now days in broad way take a look.
1) ESB : Enterprise Service Bus
2) POX : Plain OLD XML
3) REST: Representational State Transfer
4) SOAP: Simple Object Access Protocol
5) RIA : Rich Internet Application
6) XML : Extensible Markup Language
7) JASON: Java Script Object Notation
8) DOM : Document Object Modeling
9) XAML : Extensible Application Markup Language
10) LINQ : Language Integrated Query
11) RSS: Really Simple Syndication
12) WCF: Windows Communication Foundation
13) WF: Windows Foundation
14) WPF: Windows Presentation Foundation
15) AJAX: Asynchronous Java script and XML
16) XLST: Extensible Style Sheet Language Transformation
17) INDIGO: Code name of Microsoft windows Communication foundation Technology
18) OSLO: Code name of Microsoft Modeling Technology
19) SOA: Service Oriented Architecture
20) ORCAS: dot net 3.5 Version called ORCAS
21) AVALON: code name of Microsoft Windows Presentation foundation Technology
22) Azure: Microsoft new Operation system Related to Cloud computing
23) Astoria : Code name of Ado.net Data services

I hope you people like it.
Enjoy life with dot net.

Your host
Rajat Jaiswal

August 10, 2009

How to read Resource files in our code by LINQ to XML ?

Filed under: Asp.net, LINQ, XML — indiandotnet @ 4:43 am
Tags: , , , ,

Hello friends,

Sorry for such a late post. Currently I am busy in too many works so not getting enough time to talk with you.

Today I am posting an interesting work which is how to read a resource file in our code with the help of LINQ TO SQL.

I can say only one thing which is its simple and easy to use. Just copy paste below code and you will get what to want.

Before code I will explain you that resource file is just like xml which has attributes and value and that particular attributes is your key.

 

Now we need to fetch value for particular key for a file for this you have to write below code. Where bv_strFileName is your resource file name and bv_strKey is key for which you need value.

Public Shared Function pub_LangaugeValue(ByVal bv_strFile As String, ByVal bv_strKey As String) As String

Try

Dim strValue As String = “”

Dim resxXML As New XDocument

resxXML = XDocument.Load(bv_strFile)

Dim a = From data In resxXML.Root.Descendants(“data”) _

Where data.Attribute(“name”).Value = bv_strKey _

Select New With {.resxA = data.Attribute(“name”).Value, .ResxValue = data.Element(“value”).Value}

If a.Count() > 0 Then

strValue = a.FirstOrDefault().ResxValue.ToString()

Else

strValue = bv_strKey

End If

Return strValue

Catch ex As Exception

Throw ex

End Try

End Function ‘pub_LangaugeValue

 

Where bv_strFileName is full path name of our resource file and bv_strkey is the key for which we need to find the value.

Below is example how to use it our aspx.

Suppose we want to read LabelResource1.text value in Spanish whose file name is home.aspx.es.resx.

 

Then we have to call the above function like below.

Response.write(pub_LanguageValue(server.mapPath(“/App_LocalResources/home.aspx.es.resx”),”LabelResource1.text”)

With the help of above code.

We can get key’s value from different resource file.

 

Thanks

Rajat Jaiswal

January 8, 2009

LINQ tutorial Part -IV

Filed under: Asp.net, LINQ, XML — indiandotnet @ 4:47 pm
Tags: , , ,
. Linq To XML (Add ,edit ,delete ): -

 

One of the intresting topic is xml. As a programmer I am not using XML in my daily use but I like XML.

Today I just wondering to take a suitable example which will do add,edit & delete with LINQ. So first we have to Create a xml file for that lets we created a xml file with following format.

<?xml version=1.0 encoding=utf-8?>
<Trainings>
<Training>
<Id>2</Id>
<Person>RAJAT JAISWAL</Person>
<FrameWork>2</FrameWork>
<ASPNET>2</ASPNET>
<Communication>4</Communication>
<HTML>5</HTML>
<LogicBuilding>4</LogicBuilding>
<SqlServer>5</SqlServer>
<Remark>testing</Remark>
</Training>
</Trainings>
Now if we want to add new record in this xml file then our first moto is to read the xml using linq . For this we first use a import statement

Imports System.Xml.Linq by this we are able to use Linq over xml.

Now for reading we just do same as we do for database read (linq to sql ) but before that we have to create the object of xdocument from where the data will be fatch. As shown below

Dim TrainXDoc As XDocument = XDocument.Load(Server.MapPath(“MyTraining.xml”))

What this statement does it create same object like dataContext in sql.

And below is linq over this document and the Descendants(“Training”) like table or other object like storeprocedure in dbContext.

Dim lnqTraining = From myTraining In TrainXDoc.Descendants(“Training”) _

Select New With {.Id = myTraining.Element(“Id”).Value, _

.Person = myTraining.Element(“Person”).Value, _

.FrameWork = myTraining.Element(“FrameWork”).Value, _

.ASPNET = myTraining.Element(“ASPNET”).Value, _

.SqlServer = myTraining.Element(“SqlServer”).Value, _

.LogicBuilding = myTraining.Element(“LogicBuilding”).Value, _

.HTML = myTraining.Element(“HTML”).Value, _

.Communication = myTraining.Element(“Communication”).Value, _

.Remark = myTraining.Element(“Remark”).Value}

In the above elements like a row in datatable and we access there column using the tag name like Id, Person,Framework.

Now our second moto is to Add & Update the Add a new record can be done as follows

TrainXDoc .Element(“Trainings”).Add(New XElement(“Training”, New XElement(“Id”, lngId), New XElement(“Person”, Me.txtName.Text.Trim), _

New XElement(“FrameWork”, ddlFramWork.SelectedValue), New XElement(“ASPNET”, ddlAspNet.SelectedValue), _

New XElement(“Communication”, ddlCommunication.SelectedValue), New XElement(“HTML”, Me.ddlHtml.SelectedValue), _

New XElement(“LogicBuilding”, Me.ddlLogicBuilding.SelectedValue), New XElement(“SqlServer”, Me.ddlSqlServer.SelectedValue), _

New XElement(“Remark”, Me.txtRemark.Text.Trim)))

Here it added new record in traindoc’s trainings element which was root element.

After this we use MyTrainXDoc.Save(Server.MapPath(“MyTraining.xml”)) which save in the file.

For update we just find the node using the linq which we want to update then made changes in the particular node elements. And call save method as above.

For delete just find the element from linq then remove like xRoot.Remove() then save the xdoc.

For more detail just download the code from

 

http://www.indiandotnet.tk/

Thanks & Regards

Rajat Jaiswal

Blog at WordPress.com.