LINQ Tutorial with Dot Net Framework 3.0 and 3.5 LINQ Tutorial ar Dot NET Framework 3,0 un 3,5
With the advancement of technologies and database it has become a great challenge to retrieve data faster and with less burden on programming part. Ar attīstību, tehnoloģijas un datu bāzi, tā ir kļuvusi par lielu izaicinājumu ielādētu datus ātrāk un ar mazāku slogu programmēšanas daļu.
It has become apparent that the next big challenge in programming technology is to reduce the complexity of accessing and integrating information that is not natively defined using OO technology. Ir kļuvis skaidrs, ka nākamajā liels izaicinājums plānošanas tehnoloģijas, lai mazinātu sarežģītību piekļūt un integrēt informāciju, kas nav natively nosaka, izmantojot OO tehnoloģiju. The two most common sources of non-OO information are relational databases and XML. Divi visbiežāk avotiem, kas nav OO informācija ir relāciju datu bāzes un XML.
The major advantage of Galvenās priekšrocības Microsoft's LINQ Project Microsoft LINQ Project is the general approach they have taken because they have integrated a query language irrespective of any specific part.Language Integrated Query can be used with XML,Database or anything which is capable of returning IENUMERABLE. ir vispārēju pieeju tās ir veikušas, jo tās ir integrētas vaicājumu valodā, neatkarīgi no jebkādiem īpašiem part.Language Integrētā Query var lietot ar XML, datu bāzē vai jebkas, kas spēj atgriezties IENUMERABLE.
Here is a small tutorial that can explaining. Te ir neliela apmācība, kas var skaidrojumu. This is specially for my readers who love to do to porgamming. Tas ir speciāli manu lasītāju, kas love to darīt, lai porgamming.
This is a snippet which i found in the doc itself which can express the power of LINQ and make programmers of dot net really smile. Tas ir fragments ko i konstatēts, doc pati, kas var izteikt varu LINQ un dara programmētāji no dot neto tiešām smaidu.
using System; using System.Query; izmantojot sistēmu, izmantojot System.Query;
using System.Collections.Generic; izmantojot System.Collections.Generic;
class app { klases app (
static void Main() { statiskā anulēts Main () (
string[] names = { “Burke”, “Connor”, “Frank”,“Everett”, “Albert”, “George”,”Harris”, “David” }; string [] nosaukumi = ( "Burke", "Connor", "Frank", "Everett", "Alberts", "George", "Harris", "David");IEnumerable expr = from s in names IEnumerable expr = no s nosaukumi
where ( s.Length == 5 orderby s ) kur (s.Length == 5 orderby s)
select s.ToUpper(); izvēlieties s.ToUpper ();
foreach (string item in expr) foreach (string objektu expr)
Console.WriteLine(item); Console.WriteLine (postenis);} )
} )
How Linq works with XML ? Kā Linq strādā ar XML?
The extensibility of the query architecture is used in the LINQ project itself to provide implementations that work over both XML and SQL data. Par papla no query arhitektūra izmanto, LINQ projekts, lai nodrošinātu īstenošanu, kas darbojas vairāk nekā gan XML un SQL datu.
Xpath and Xquery which is used heavily is in the host programming language. Xpath un Xquery, kuru izmanto ļoti ir uzņēmējas programmēšanas valoda. Here is again a code snippet for showing how easy it is to work with LINQX(yes that's what its called for XML's) Šeit atkal ir koda fragments, kas parāda, cik viegli ir strādāt ar LINQX (jā, ka ir redzams, kas to sauc par XML's)
The Standard way is done as follows: Standarts veids ir darīt šādi:
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument ();
XmlElement name = doc.CreateElement(”name”); XmlElement name = doc.CreateElement ( "nosaukums");
name.InnerText = “Patrick Hines”; name.InnerText = "Patrick Hines";
XmlElement phone1 = doc.CreateElement(”phone”); XmlElement phone1 = doc.CreateElement ( "tālrunis");
phone1.SetAttribute(”type”, “home”); phone1.SetAttribute ( "tips", "mājas");
XmlElement phone2 = doc.CreateElement(”phone”); XmlElement phone2 = doc.CreateElement ( "tālrunis");
phone2.SetAttribute(”type”, “work”); phone2.SetAttribute ( "Tips", "darbu");
XmlElement street1 = doc.CreateElement(”street1″); XmlElement street1 = doc.CreateElement ( "street1");
XmlElement city = doc.CreateElement(”city”); XmlElement pilsētas = doc.CreateElement ( "pilsētas");
city.InnerText = “Mercer Island”; city.InnerText = "Mercer Island";
XmlElement state = doc.CreateElement(”state”); XmlElement valsts = doc.CreateElement ( "valsts");
state.InnerText = “WA”; state.InnerText = "WA";
XmlElement postal = doc.CreateElement(”postal”); XmlElement pasta = doc.CreateElement ( "pasta");
postal.InnerText = “68042″; postal.InnerText = "68042";
XmlElement address = doc.CreateElement(”address”); XmlElement adrese = doc.CreateElement ( "adrese");
address.AppendChild(street1); address.AppendChild (street1);
address.AppendChild(city); address.AppendChild (pilsētas);
address.AppendChild(state); address.AppendChild (valsts);
address.AppendChild(postal); address.AppendChild (pasta);
XmlElement contact = doc.CreateElement(”contact”); XmlElement kontaktu = doc.CreateElement ( "kontakts");
contact.AppendChild(name); contact.AppendChild (nosaukums);
contact.AppendChild(phone1); contact.AppendChild (phone1);
contact.AppendChild(phone2); contact.AppendChild (phone2);
contact.AppendChild(address); contact.AppendChild (adrese);
XmlElement contacts = doc.CreateElement(”contacts”); XmlElement kontakti = doc.CreateElement ( "kontakti");
contacts.AppendChild(contact); contacts.AppendChild (kontakti);
doc.AppendChild(contacts); doc.AppendChild (kontaktus);
If we see it little closer the above code , This style of coding provides few clues to the structure of the XML tree. Ja mēs tā nedaudz tuvāk iepriekš kods, Šī stila kodēšana paredz dažas clues lai struktūru XML koku. but with LINQX it becomes more of what they as functional construct.Here is what how u code the same with LINQX…. bet ar LINQX kļūs par to, ko viņi, funkcionālie construct.Here ir tas, ko, kā un kods to pašu ar LINQX ....
XElement contacts = new XElement XElement kontaktus = new XElement
(”contacts”,new XElement(”contact”, ( "Kontakti", jaunas XElement ( "kontakts",
new XElement(”name”, “Patrick Hines”), jauns XElement ( "vārds", "Patrick Hines"),
new XElement(”phone”, “206-555-0144″, jauns XElement ( "tālrunis", "206-555-0144"
new XAttribute(”type”, “home”)) jauns XAttribute ( "tips", "home"))
,new XElement(”phone”, “425-555-0145″,new XAttribute(”type”, “work”)), , jaunas XElement ( "tālrunis", "425-555-0145", jauns XAttribute ( "tips", "darbs")),
new XElement(”address”,new XElement(”street1″, “123 Main t”), jauns XElement ( "address", jaunas XElement ( "street1", "123 Main t"),
new XElement(”city”, “Mercer Island”), jauns XElement ( "pilsēta", "Mercer Island"),
new XElement(”state”, “WA”),new XElement(”postal”,”6843″) jauns XElement ( "valsts", "WA"), jauns XElement ( "pasta", "6843")
This is so simple no hassles at all. Tas ir tik vienkārši nav hassles vispār.
How LINQ works with database Kā LINQ strādā ar datu bāzi
Yup its done By Microsoft again under LINQD(thats LINQ for database). Yup to izdarīt, Microsoft atkārtoti LINQD (tas ir LINQ par datu bāzi). The query operators over relational data (DLinq) build on the integration of SQL-based schema definitions into the CLR type system. Vaicājuma tirgus dalībnieku relāciju datu (DLinq) izveidot par integrāciju SQL balstītas schema definīcijas iekļaušana CLR tipa sistēmu.
This integration provides strong typing over relational data while retaining the expressive power of the relational model and the performance of query evaluation directly in the underlying store. Šī integrācija nodrošina spēcīgu mašīnrakstīšanu pār relāciju datu saglabājot ekspresīvs jauda, kas relāciju modelis un veiktspēju jautājumu novērtējumu, kas ir tieši notikušajos veikalā.
What we kneed to know is the structure of database table we want to deal with it and create a class exactly having private variables as columns of the underlying table say may be like save that easy.Thus in simple way we create an object of the row of that table in memory and do operation on that and ask somebody to save it.Moreover we can ask for a collection of those rows fo get more than one record and do a query on it..isnt that great no hassles of database sql. Ko mēs kājām zināt ir struktūru datu bāzes tabulu mēs gribam, lai tiktu galā ar to un izveidot klases tieši ņemot privāto mainīgajiem lielumiem, kā kolonnas par notikušo galda teikt var būt, piemēram, glābt šo easy.Thus vienkāršā veidā mēs izveidojam objekts rindā uz šo tabulu atmiņā, un tie darbojas, ka un uzdot kādam, lai saglabātu it.Moreover mēs varam lūgt kolekciju tās rindas iegūtu vairāk nekā viens ieraksts, un tie ir jautājumi par to .. isn't, ka liels nav hassles datu bāzes SQL.
1. 1. Create an entity class with mapping to database table like this:- Izveidot uzņēmums klases ar kartēšanu, lai datu bāzes tabulā, piemēram, šī: --
[Table(Name="Customers")] [Tabula (Name = "klienti")]
public class Customer valsts klases klientu
{ (
[Column (Id=true)] [Sleja (Id = true)]
public string CustomerID; valsts stīgu KlientaID;
private string _City; privātā string _City;
[Column(Storage = "_City")] [Column (Storage = "_City")]
public string City valsts string City
{ (
get { return this._City; } get (atgriešanās this._City;)
set { this._City = value; }}} noteikt (this._City = vērtība;)))
2.Create a Data context to load from database 2.Create datu kontekstā ielādēt no datu bāzes
static void Main(string[] args){ statiskā anulēts Main (string [] args) (
// Use a standard connection string / / Izmantot standarta savienojums string
DataContext db = new DataContext( DataContext db = new DataContext (
@”C:Program FilesLINQ PreviewDatanorthwnd.mdf”); @ "C: Program FilesLINQ PreviewDatanorthwnd.mdf");
// Get a typed table to run queries / / Get a drukāti tabulu, lai palaistu vaicājumus
Table Customers = db.GetTable(); Tabula Customers = db.GetTable ();
3.Query what you get…. 3.Query to, kas jums ....
// Attach the log showing generated SQL to console / / Pievienojiet log parādot generated SQL lai konsole
// This is only for debugging / understanding the working of DLinq / / Šis ir tikai debugging / izpratni par darba DLinq
db.Log = Console.Out; db.Log = Console.Out;
// Query for customers in London / / Query klientiem Londonā
var custs = var custs =
from c in Customers no C Pircējiem
where c.City == “London” kur c.City == "London"
select c; izvēlieties c;
} )
Thats how it works with database….easy isn't it…This Technology will come with Tas ir, kā tā darbojas ar datu bāzi. ... Viegli nav tas ... Šī tehnoloģija nāks ar DotNet Framework 3.0 DotNet pamatprogrammas 3,0 and with C#3.0 and VB 9. un ar C # 3,0 un VB 9. I havent covered every thing but just a quick glance which can get grasping things faster. I havent uz katru lieta, bet tikai ātri mirklī, kas var saņemt grasping lietas ātrāk. If you want to read more on it see the Ja jūs vēlaties lasīt vairāk par to aplūkotu Microsoft's LINQ Project Microsoft LINQ Project
Related : Related: Linq provider for Twitter API Linq sniedzēju čivināt API
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |

Posted on 21st May 2007 by Posted par 21 maijs 2007 Ashish Mohta Ashish Mohta , A tech blogger who writes about solving day to day problems of people who use computer. , A tech blogger, kas raksta par risināšana ikdienas problēmas, kas saistītas ar cilvēkiem, kuri lieto datoru. He also writes on How to use the applications like Office, PC tips, Online tools,Browsers and more. All posts by Viņš arī raksta par to, kā izmantot lietojumiem, piemēram, Office, PC padomus, Online instrumentus, pārlūkprogrammas un vairāk. Visi amatu ar Ashish Mohta Ashish Mohta | Connect with me @ | Sazinieties ar mani @ Twitter Čivināt | | Linkedin Linkedin | | Facebook Facebook | | Stumble Paklupt | Need more help? | Vajadzīga palīdzība? Ask your Questions at our Jautājiet pēc mūsu Support Center Support Center

























I don't understand….you write on how to use tools in office, when one of the most basic (spellchecker) obviously went unused in this report. Es nesaprotu .... Rakstīt par to, kā izmantot līdzekļus, biroja, kad viens no pamata (spellchecker), protams, gāja neizmantoto šajā ziņojumā. Thumbs way down to you Hashish. Thumbs veidā uz leju, lai jūs hašišs. Way down. Ceļš uz leju.
Hi Oliver, Why dont you enlighten all of us reading this with your devine knowledge on this subject ? Hi Oliver, Kāpēc dont jums paskaidrot mums visiem lasījumā to ar savu Devine zināšanas par šo tēmu?
Regards Sveicieni
ASHISH ( without start H in Hashish ) ASHISH (bez sākt H hašišs)
heavily — heavily stipri - stipri
explaing — explain explaing - paskaidrot
lil ??? lil? — little - Maz
fo — to par - lai
hassels — hassels hassels - hassels
isint — isn't isint - nav
Frameowrk – Framework Frameowrk - pamatnosacījumi
Here is a free tip for you — Tools > Spelling and Grammar… Te ir bezmaksas tip par jums - Tools> Pareizrakstība un gramatika ...
@Stjepan and Oliver : Thanks for pointing it out. @ Stjepan un Oliver: Paldies par norādot tā out. I guess I still get scolded for my older posts but thanks. I guess I vēl saņemt scolded manu vecāku amatu bet thanks. I had made the corrections Man bija veikusi korekcijas
Hello, Ashish, thanks for the post. Hello, Ashish, Thanks for the post. As for Stjepan lol he still spelt Hassles wrong. Attiecībā uz Stjepan lol viņš joprojām speltas Hassles wrong. So sad. Tātad skumjš. Enjoy. Baudīt. Keep up the good work Keep up labu darbu
Thanks Tisso!! Thanks Tisso!
Leave your response! Atstājiet savu reakciju!
Search
Subscribe for Daily Updates
Free Feed Subscription
Monthly Archives
Topics
What others are Saying ?