Home घर » » Dot Net डॉट नेट

LINQ Tutorial with Dot Net Framework 3.0 and 3.5 LINQ डॉट नेट Tutorial फ्रेमवर्क 3,0 और 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. प्रौद्योगिकियों और डेटाबेस यह तेजी से डेटा पुनः प्राप्त करने के लिए और प्रोग्रामिंग भाग पर कम बोझ के साथ एक बड़ी चुनौती बन गया है की उन्नति के साथ.

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. ऐसा लगता है कि प्रोग्रामिंग प्रौद्योगिकी के क्षेत्र में अगले बड़ी चुनौती तक पहुँचने और सूचना है कि natively ऊ प्रौद्योगिकी का उपयोग करके परिभाषित नहीं है समेकित करने की जटिलता को कम करने के लिए है स्पष्ट हो गया है. The two most common sources of non-OO information are relational databases and XML. गैर की दो सबसे आम स्रोतों-ऊ जानकारी संबंधपरक डेटाबेस और XML हैं.

The major advantage of प्रमुख लाभ का Microsoft's LINQ Project माइक्रोसॉफ्ट के LINQ परियोजना 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. क्योंकि वे XML, डाटाबेस या जो IENUMERABLE लौटने में सक्षम है कुछ के साथ प्रयोग किया जा सकता है किसी भी विशिष्ट part.Language समन्वित क्वेरी भले के एक क्वेरी भाषा एकीकृत हैं वे ले लिया है आम तरीका है.

Here is a small tutorial that can explaining. यहाँ है एक ट्यूटोरियल है कि छोटे से समझा सकते हैं. This is specially for my readers who love to do to porgamming. यह विशेष रूप से जो 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. यह जो मैं डॉक्टर ही जो LINQ की शक्ति व्यक्त कर सकते हैं और के प्रोग्रामर बनाने शुद्ध सचमुच मुस्कान डॉट में पाया एक टुकड़ा है.

using System; using System.Query; सिस्टम का उपयोग करते हुए, System.Query का उपयोग करते हुए;
using System.Collections.Generic; System.Collections.Generic का उपयोग करते हुए;
class app { वर्ग app (
static void Main() { स्थैतिक शून्य मुख्य () (
string[] names = { “Burke”, “Connor”, “Frank”,“Everett”, “Albert”, “George”,”Harris”, “David” }; स्ट्रिंग [] के नाम = ( "बर्क", "Connor", "फ्रैंक", "Everett", "अल्बर्ट", "जॉर्ज", "हैरिस", "दाऊद");

IEnumerable expr = from s in names IEnumerable expr = से नामों में s
where ( s.Length == 5 orderby s ) जहाँ (s.Length == 5 orderby s)
select s.ToUpper(); चुनें s.ToUpper ();
foreach (string item in expr) expr में foreach (स्ट्रिंग मद)
Console.WriteLine(item); Console.WriteLine (मद);

} )

} )

How Linq works with XML ? कैसे Linq 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. क्वेरी वास्तुकला के तानाना के LINQ में implementations प्रदान करने के लिए खुद को प्रोजेक्ट किया जाता है कि दोनों एक्सएमएल और SQL डेटा पर काम करते हैं.

Xpath and Xquery which is used heavily is in the host programming language. Xpath और जो Xquery भारी प्रयोग किया जाता है मेजबान प्रोग्रामिंग भाषा में है. 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) फिर से यहाँ कैसे आसान यह LINQX के साथ (हाँ यह काम करने के लिए है दिखाने के लिए एक कोड का टुकड़ा है जो इसके लिए बुलाया एक्सएमएल है)

The Standard way is done as follows: इस मानक तरीके के रूप में किया है प्रकार है:

XmlDocument doc = new XmlDocument(); XmlDocument डॉक्टर = नए XmlDocument ();
XmlElement name = doc.CreateElement(”name”); XmlElement नाम = doc.CreateElement ( "नाम");
name.InnerText = “Patrick Hines”; name.InnerText = "पैट्रिक Hines";
XmlElement phone1 = doc.CreateElement(”phone”); XmlElement phone1 = doc.CreateElement ( "फोन");
phone1.SetAttribute(”type”, “home”); phone1.SetAttribute ( "प्रकार", "घर");
XmlElement phone2 = doc.CreateElement(”phone”); XmlElement phone2 = doc.CreateElement ( "फोन");
phone2.SetAttribute(”type”, “work”); phone2.SetAttribute ( "प्रकार", "काम");
XmlElement street1 = doc.CreateElement(”street1″); XmlElement street1 = doc.CreateElement ( "street1");
XmlElement city = doc.CreateElement(”city”); XmlElement शहर = doc.CreateElement ( "शहर");
city.InnerText = “Mercer Island”; city.InnerText = "Mercer द्वीप";
XmlElement state = doc.CreateElement(”state”); XmlElement राज्य = doc.CreateElement ( "राज्य");
state.InnerText = “WA”; state.InnerText = "WA";
XmlElement postal = doc.CreateElement(”postal”); XmlElement डाक = doc.CreateElement ( "डाक");
postal.InnerText = “68042″; postal.InnerText = "68042";
XmlElement address = doc.CreateElement(”address”); XmlElement पता = doc.CreateElement ( "पते");
address.AppendChild(street1); address.AppendChild (street1);
address.AppendChild(city); address.AppendChild (नगर);
address.AppendChild(state); address.AppendChild (राज्य);
address.AppendChild(postal); () डाक address.AppendChild;
XmlElement contact = doc.CreateElement(”contact”); XmlElement संपर्क = doc.CreateElement ( "संपर्क");
contact.AppendChild(name); (नाम) contact.AppendChild;
contact.AppendChild(phone1); contact.AppendChild (phone1);
contact.AppendChild(phone2); contact.AppendChild (phone2);
contact.AppendChild(address); contact.AppendChild (पते);
XmlElement contacts = doc.CreateElement(”contacts”); XmlElement संपर्क = doc.CreateElement ( "संपर्क");
contacts.AppendChild(contact); contacts.AppendChild (संपर्क);
doc.AppendChild(contacts); doc.AppendChild (संपर्क);

If we see it little closer the above code , This style of coding provides few clues to the structure of the XML tree. अगर हम थोड़ा करीब उपरोक्त कोड, कोडन की यह शैली के लिए XML के पेड़ की संरचना करने के लिए कुछ सुराग प्रदान करता है यह देखने. but with LINQX it becomes more of what they as functional construct.Here is what how u code the same with LINQX…. लेकिन LINQX के साथ वे के रूप में कार्य construct.Here क्या कैसे U कोड के LINQX के साथ ही क्या है की अधिक हो जाता है ....

XElement contacts = new XElement XElement संपर्क = नए XElement
(”contacts”,new XElement(”contact”, ( "संपर्क", नए XElement ( "संपर्क",
new XElement(”name”, “Patrick Hines”), नई XElement ( "नाम", "पैट्रिक Hines"),
new XElement(”phone”, “206-555-0144″, नई XElement ( "फोन", "206-555-0144",
new XAttribute(”type”, “home”)) नई XAttribute ( "प्रकार", "घर"))
,new XElement(”phone”, “425-555-0145″,new XAttribute(”type”, “work”)), , नई XElement ( "फोन", "425-555-0145", नए XAttribute ( "प्रकार", "काम")),
new XElement(”address”,new XElement(”street1″, “123 Main t”), नई XElement ( "पते", नए XElement ( "street1", "123 मुख्य t"),
new XElement(”city”, “Mercer Island”), नई XElement ( "शहर", "Mercer द्वीप"),
new XElement(”state”, “WA”),new XElement(”postal”,”6843″) नई XElement ( "राज्य", "WA"), नई XElement ( "" डाक, "6843")

This is so simple no hassles at all. यह तो नहीं बाधाओं को बिल्कुल सरल है.

How LINQ works with database कैसे LINQ डाटाबेस के साथ काम करता है

Yup its done By Microsoft again under LINQD(thats LINQ for database). हाँ इसके माइक्रोसॉफ्ट से फिर LINQD (Thats LINQ अंतर्गत डेटाबेस के लिए किया गया). The query operators over relational data (DLinq) build on the integration of SQL-based schema definitions into the CLR type system. संबंधपरक डेटा (DLinq) पर इस क्वेरी ऑपरेटरों SQL के एकीकरण पर निर्माण को CLR प्रकार प्रणाली में स्कीमा परिभाषा आधारित.

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. जबकि सीधे नीचे की दुकान में संबंधपरक मॉडल के भाववाहक शक्ति और क्वेरी मूल्यांकन के प्रदर्शन को बनाए रखने यह एकीकरण संबंधपरक डेटा पर मजबूत टाइपिंग प्रदान करता है.

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. क्या पता करने के लिए हम घुटनों का डेटाबेस तालिका के हम इसे से निपटने के लिए चाहते हैं और एक वर्ग बिल्कुल मौलिक सारणी के कॉलम के रूप में निजी चर रही बनाने संरचना है हम इस पंक्ति के एक वस्तु बना आसान तरीका है कि easy.Thus बचाने की तरह किया जा सकता है कहना स्मृति में उस तालिका की और संचालन कर उस पर और किसी it.Moreover हम उन पंक्तियों का संग्रह करने के लिए के लिए पूछ सकते हैं बचाने के लिए पूछना एक रिकार्ड से अधिक हो और यह .. isn't पर एक प्रश्न है कि डाटाबेस sql के महान नहीं बाधाओं को.

1. 1. Create an entity class with mapping to database table like this:- इस तरह डेटाबेस तालिका के मानचित्रण के साथ एक इकाई वर्ग बनाएँ: --

[Table(Name="Customers")] [टैबिल (नाम = "ग्राहक")]
public class Customer सार्वजनिक वर्ग ग्राहक
{ (
[Column (Id=true)] [कॉलम (id =) सच]
public string CustomerID; सार्वजनिक स्ट्रिंग CustomerID;
private string _City; निजी स्ट्रिंग _City;
[Column(Storage = "_City")] [कॉलम (संग्रहण = "_City")]
public string City सार्वजनिक स्ट्रिंग सिटी
{ (
get { return this._City; } (वापसी this._City;) मिल
set { this._City = value; }}} सेट (this._City = मूल्य;)))

2.Create a Data context to load from database एक डाटा संदर्भ 2.Create डाटाबेस से लोड करने के लिए

static void Main(string[] args){ मुख्य स्थैतिक शून्य (स्ट्रिंग [] args) (
// Use a standard connection string / / एक मानक कनेक्शन स्ट्रिंग का उपयोग करें
DataContext db = new DataContext( DataContext DB = नए DataContext (
@”C:Program FilesLINQ PreviewDatanorthwnd.mdf”); @ "सी: कार्यक्रम FilesLINQ PreviewDatanorthwnd.mdf");
// Get a typed table to run queries / / प्रश्नों को चलाने के लिए एक टाइप की मेज जाओ
Table Customers = db.GetTable(); टैबिल ग्राहक = db.GetTable ();

3.Query what you get…. 3.Query तुम क्या हो ....

// Attach the log showing generated SQL to console / / संलग्न को दिलासा देने के लिए SQL उत्पन्न दिखा लॉग
// This is only for debugging / understanding the working of DLinq / / यह केवल Debugging के लिए है / DLinq के काम को समझने
db.Log = Console.Out; db.Log = Console.Out;
// Query for customers in London / / लंदन में ग्राहकों के लिए क्वेरी
var custs = var custs =
from c in Customers ग्राहकों में ग से
where c.City == “London” जहां c.City == "लंदन"
select c; ग चयन करें;
} )

Thats how it works with database….easy isn't it…This Technology will come with Thats यह कैसे डाटाबेस के साथ काम करता है .... आसान के साथ आ जाएगा कि नहीं ... यह प्रौद्योगिकी है DotNet Framework 3.0 DotNet Framework 3.0 and with C#3.0 and VB 9. और सी # 3,0 और VB 9 के साथ. I havent covered every thing but just a quick glance which can get grasping things faster. लेकिन मैं हर चीज को कवर havent, जो तेजी से बातें लोभी मिल सकती है तो बस एक नज़र. If you want to read more on it see the यदि आप इस पर और अधिक पढ़ने के लिए चाहते हैं कि देखने Microsoft's LINQ Project माइक्रोसॉफ्ट के LINQ परियोजना

Related : संबंधित: Linq provider for Twitter API चहचहाना एपीआई के लिए Linq प्रदाता

Tagged with: के साथ टैग की गईं:

Translate to EnglishÜbersetzen Sie zum Deutsch/GermanΜεταφράστε στα ελληνικά/GreekПереведите к русскому/RussianOversetter til Norsk/NorwegianÖversätta till Svensk/Swedishहिन्दी अनुवाद करने के लिए/Hindi
Tradueix al català/CatalanTulkot uz latviešu/LatvianPreložiť do slovenčiny/SlovakVertaal aan het Nederlands/Dutchترجمة الى العربية/ArabicTraduzca al Español/SpanishTraduisez au Français/French
Traduca ad Italiano/ItalianTraduza ao Português/Portuguese日本語に翻訳しなさい /Japanese한국어에게 번역하십시오/Korean中文翻译/Chinese Simplified中文翻译/Chinese TraditionalПереклад на українську/Ukrainian

एसएमएस सदस्यताPrint This Post

Posted on 21st May 2007 by 21 मई 2007 पर द्वारा पोस्ट Ashish Mohta आशीष Mohta , A tech blogger who writes about solving day to day problems of people who use computer. है, जो दिन के बारे में है जो कम्प्यूटर का इस्तेमाल लोगों की दिन समस्याओं को हल करने के लिए लिखता है एक टेक ब्लॉगर. He also writes on How to use the applications like Office, PC tips, Online tools,Browsers and more. All posts by उन्होंने यह भी कैसे कार्यालय, पीसी युक्तियाँ, ऑनलाइन उपकरण, ब्राउज़र्स और अधिक जैसे अनुप्रयोगों का उपयोग करने पर लिखता है. सभी पदों से Ashish Mohta आशीष Mohta | Connect with me @ | कनेक्ट मेरे साथ @ Twitter चहचहाना | | Linkedin Linkedin | | Facebook Facebook | | Stumble ठोकर | Need more help? | और अधिक मदद की जरूरत है? Ask your Questions at our पर अपने प्रश्न पूछें हमारे Support Center सहायता केंद्र

6 Comments 6 टिप्पणियाँ » »

  • Oliver ओलिवर said: ने कहा:

    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. मुझे समझ में नहीं आता है .... आप कैसे कार्यालय, जब एक सबसे बुनियादी (spellchecker के) जाहिर अप्रयुक्त इस रिपोर्ट में गया में उपकरण का उपयोग करने पर लिखें. Thumbs way down to you Hashish. तुम से अंगूठे रास्ता नीचे चरस. Way down. रास्ते नीचे.

  • Ashish Mohta आशीष Mohta (author) said: (लेखक) ने कहा:

    Hi Oliver, Why dont you enlighten all of us reading this with your devine knowledge on this subject ? हाय ओलिवर, तुम क्यों हम सब को इस विषय पर अपने devine ज्ञान के साथ इस पढ़ने जानकारी न?

    Regards सादर
    ASHISH ( without start H in Hashish ) आशीष चरस में शुरू एच () के बिना

  • Stjepan said: Stjepan ने कहा:

    heavily — heavily भारी - भारी
    explaing — explain explaing - समझा
    lil ??? lil??? — little - छोटी
    fo — to के लिए - करने के लिए
    hassels — hassels hassels - hassels
    isint — isn't isint - नहीं है
    Frameowrk – Framework Frameowrk - फ्रेमवर्क

    Here is a free tip for you — Tools > Spelling and Grammar… यहाँ आप के लिए एक स्वतंत्र टिप है - टूल्स> वर्तनी और व्याकरण ...

  • Ashish Mohta आशीष Mohta (author) said: (लेखक) ने कहा:

    @Stjepan and Oliver : Thanks for pointing it out. @ Stjepan और ओलिवर: यह इंगित करने के लिए धन्यवाद. I guess I still get scolded for my older posts but thanks. मुझे लगता है मैं अभी भी अपने पुराने पदों पर धन्यवाद के लिए डांटा मिल लगता है. I had made the corrections मैं सुधार किया था

  • Tiiso :D said: Tiiso: डी ने कहा:

    Hello, Ashish, thanks for the post. हैलो, आशीष, इस पोस्ट के लिए धन्यवाद. As for Stjepan lol he still spelt Hassles wrong. Stjepan के लिए lol के रूप में वह अभी भी जाहिर की बाधाओं को गलत. So sad. तो दुख की बात है. Enjoy. आनंद लेना. Keep up the good work अच्छा काम जारी रखो : डी

  • Ashish Mohta आशीष Mohta (author) said: (लेखक) ने कहा:

    Thanks Tisso!! धन्यवाद Tisso!!

Leave your response! आपकी प्रतिक्रिया छोड़ दो!

Be nice. अच्छे बनो. Keep it clean. यह साफ रखें. Stay on topic. रहो विषय पर. No spam. स्पैम नहीं.

You can use these tags: आप इन टैग का उपयोग कर सकते हैं:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>