Skip to content

LINQ

LINQ (all flavours)

This category can be followed from the open social web via the handle linq-e04cf296@forum.codeproject.com

783 Topics 2.8k Posts
  • Group by without a Group

    database csharp linq question
    6
    0 Votes
    6 Posts
    5 Views
    H
    Guess what.. the SQL generated by LINQ to SQL runs two queries, not one!! Maybe MS needs to work on the query engine some.. 'Howard
  • 0 Votes
    3 Posts
    2 Views
    K
    Thanks Richards, i will try that and let u know the result.
  • where clause in LINQ

    csharp database linq
    4
    0 Votes
    4 Posts
    3 Views
    B
    hi im not sure whether contains will b ok.To be specific u can use this for like type of queries from a in db.client where SqlMethods.Like(a.Client_Name, "%abc%") select ... sqlmethods have other methods like datwediffday,datediffsecond,datediffhour etc prior writing this include this namespace using System.Data.Linq.SqlClient; T.Balaji
  • how to return a string variable in sp ?

    help csharp sharepoint database tutorial
    13
    0 Votes
    13 Posts
    4 Views
    B
    hi kelly Thanx for ur timely help.i understood now..il try and let u know T.Balaji
  • GridView using LINQ

    csharp database linq xml help
    3
    0 Votes
    3 Posts
    2 Views
    I
    Thank you Howard!! You gave me exactly what I was looking for. I have implemented it and it works!! I very much Appreciate it!! Illegal Operation
  • validation in database

    database
    3
    0 Votes
    3 Posts
    2 Views
    P
    That's a tough one, because between you checking for uniqueness and you actually inserting your record, somebody else could insert the same record. Ways that this can be achieved would normally be outside the scope of typical LINQ operations. For instance, one way would be to do an insert with the check as part of the condition, e.g. insert into mytable(name) select @name where not exists .... Deja View - the feeling that you've seen this post before. My blog | My articles
  • Reuse Linq query

    database csharp linq
    4
    0 Votes
    4 Posts
    2 Views
    H
    Firstly.. remember that ASP.NET does not persist the data between creating the page and a postback..you can store variables on a page but they are not persisted on the server.* user requests page -> code is executed -> html returned -> discarded user clicks button -> code is executed -> html returned -> discarded Hence there is no point in writing the var query and storing it - this is the wrong approach with ASP.NET. Secondly the query "var query = from s in db.Suppliers select s;" is a query definition, and NOT a result set. LINQ to SQL does not execute a query until you ask it to do something with it, such as bind it to the control(s) or enumerate it. So the answer is "you don't need to" - just write the query in place as needed, e.g. void ShowData(int startRow) { var db = new DataContext(); var query = from s in db.Suppliers skip 0startRow take pageSize select s; this.Gridview1.DataSource = query; } Hope this helps 'Howard
  • Usomg Linq to select multiple types of object

    csharp database linq xml
    2
    0 Votes
    2 Posts
    3 Views
    A
    var s = XDocument.Load("rect.xml"); var q = from x in s.Descendants() select new { x }; XNamespace ns = "http://tempuri.org/svg11-flat-20030114"; foreach (var itm in q) { if (itm.x.Name == ns + "rect") { rect re = (rect)itm.x; Console.WriteLine(itm.x.Name.ToString()); } if (itm.x.Name == ns + "desc") { rect re = (rect)itm.x; Console.WriteLine(itm.x.Name.ToString()); } }
  • Returning Linq queries from wcf.

    csharp database question sql-server wcf
    3
    0 Votes
    3 Posts
    5 Views
    D
    I found yet another way @ http://blogs.msdn.com/kaevans/archive/2007/09/03/wcf-and-linq.aspx. "Click on the designer surface in your .dbml file and change the Serialization property to "Unidirectional". That will decorate the generated classes with DataContract and DataMember attributes appropriately."
  • 0 Votes
    7 Posts
    3 Views
    P
    Perhaps compile that part into a DLL using the command-line compiler? So far I've found that HashSet is the only compelling reason to switch to .net 3.5 (and VS 2008).
  • how to check for null inside LINQ?

    database csharp linq help tutorial
    3
    0 Votes
    3 Posts
    4 Views
    M
    The C# equivalent of isnull is the ?? operator. So, you can do the following: var x = (from a in db.stock select new { a.stockid }).Distinct(); int c = x.Max(a => a.stockid ?? 0) + 1; Or, if you want to filter null values in the query: var x = (from a in db.stock select new { stockid = (a.stockid ?? 0) }).Distinct(); int c = x.Max(a => a.stockid) + 1;
  • How to return a string value using LINQ?

    help csharp sharepoint database linq
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • Linq + DateTime weirdness

    csharp question database linq
    3
    0 Votes
    3 Posts
    3 Views
    H
    Thanx Gideon. that helped Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.passion != Programming)
  • subquery in LINQ

    csharp database linq help question
    4
    0 Votes
    4 Posts
    3 Views
    P
    balaji.t wrote: Wont it return error "single row subquery returning more than 1 row"? Is there any equivalent keyword like "in"?i mean can we use like this? No - it won't. Try it and see. Deja View - the feeling that you've seen this post before. My blog | My articles
  • Framework 3.5,MDI form

    tutorial question
    2
    0 Votes
    2 Posts
    2 Views
    J
    This forum is specifically for new functionality in .NET 3.5, such as LINQ. I recommend you ask this question in the C# programming forum. Life, family, faith: Give me a visit. From my latest post: "The themes and truths of the Jewish holidays follow God's complete plan for this world. They are the root from which Christianity sprang and the historical reasons the church had for leaving them behind were unsound." Judah Himango
  • IndexOutOfRangeException on DataContext.SubmitChanges

    database help question
    5
    0 Votes
    5 Posts
    3 Views
    R
    I think it didn't like me changing the names of some properties in the Contact class. I did change it through the designer though, so I have no idea why it's complaining. Well that was a waste of a day and a half. Thanks, Rei
  • Visual Studio 2008 is being weird with me

    csharp help question asp-net visual-studio
    3
    0 Votes
    3 Posts
    4 Views
    B
    There is nothing, just New Project.
  • 0 Votes
    3 Posts
    2 Views
    J
    Yep, using LINQ to SQL, you call SubmitChanges on the DataContext. Life, family, faith: Give me a visit. From my latest post: "We are Christian, resistance is futile. Your Jewish traits will be assimilated into the Church collective." Judah Himango
  • Optimizing LINQ query

    database csharp linq question learning
    8
    0 Votes
    8 Posts
    6 Views
    D
    Just found this tool thanks to your post. Very handy and cool! :-D Dave BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
  • 0 Votes
    2 Posts
    3 Views
    P
    Why not write a program that uses both and compare? "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon