linq

LINQ query help plz

I'm trying to convert this SQL query to LINQ: SELECT Items.p_Name Product, DiamondCategory.dc_Name Category, Diamond.d_Weight Weight FROM DiamondCategory INNER JOIN Diamond ON DiamondCategory.dc_Id = Diamond.dc_Id INNER JOIN Items ON Diamond.p_Id = Items.p_Id where Items.p_Id = 1 Union gives no results: var qry = (from d in myDatabas...

How to transcribe SQL to LINQ

select * form autor inner join (carte inner join carte_autor using id_carte) using id_autor group by id_autor; How can I write this using LINQ? Thanks. ...

Link To SQL Join Statement with or Clause

I have to following SQL Statement that I want to conver to LINQ Select F.FooName B.BarName From Foo F Inner Join Bar B on B.BarName = F.FooName OR B.BarName + 'hello' = F.FooName I have seen Inner joins in Link on multiple conditions with AND Clauses but not using OR The following is as far as I have gotten var myresult = from f ...

Binding LINQ query to DataGridView

This is very confusing, I use AsDataView to bind query result to a dgv and it works fine with the following: var query = from c in myDatabaseDataSet.Diamond where c.p_Id == p_Id select c; dataGridView1.DataSource = query.AsDataView(); However, this one results in an Error: var query = from item in myDatabaseDataSet.Items where it...

creating Linq to sqlite dbml from DbLinq source code

Hi All, I tried to create linq-to-sqlite dbml using DbLinq but in vain. Each time I get different type of errors. May be I'm somewhere wrong. Can anyone tell me the step by step procedure to create the dbml file from the Dblinq source code. ...

Can we convert all SQL scripts to Linq-to-SQL expressions or there is any limitation?

I want to convert all of my db stored procedures to linq to sql expressions, is there any limitation for this work? you must notice that there is some complicated queries in my db. ...

How to Filter out null rows from DataTable with linq??

Hi, I have a Datable that I have built from excel data, but sometimes excel returns rows in which all the fields are null. I'd like to filter these out generically without regard for column names. I think Linq would do this nicely but having a bit of trouble getting this to happen. So far this is what I got: var nonemptyrows = from...

Using Lambda Expressions trees with IEnumerable

I've been trying to learn more about using Lamba expression trees and so I created a simple example. Here is the code, this works in LINQPad if pasted in as a C# program. void Main() { IEnumerable<User> list = GetUsers().Where(NameContains("a")); list.Dump("Users"); } // Methods public IEnumerable<User> GetUsers() { yield r...

LINQ how to add an order by to this statement?

I have the following LINQ that I would like to also order by file creation date, how is this done? taskFiles = taskDirectory.GetFiles(Id + "*.xml") .Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase)) .ToArray(); ...

What's the next big thing after LINQ?

I started using LINQ (Language Integrated Query) when it was still in beta, more specifically Microsoft .NET LINQ Preview (May 2006). Almost 4 years have passed and here we are using LINQ in a lot of projects for the most diverse tasks. I even wrote my final college project based on LINQ. You see how I like it. LINQ and more recently P...

How to get all rows but specifc columns from a DataTable?

Currently i am having some problems with getting some data out of a DataTable by selecting all rows, but only some columns. To be a little more descriptive here is a little example: Sample Data | ID | FirstName | LastName | Age | +----+-----------+----------+-----+ | 1 | Alice | Wannabe | 22 | | 2 | Bob | Consumer | 27 ...

Add elements to XDocument after LINQ Query

I have the following XML LINQ query from my XDocument. var totals = (from x in MyDocument.Descendants("TOTALS") select x).FirstOrDefault(); Once I have found my totals node I need to add some elements to that node and push that change to the XDocument. ...

What is the difference between these 2 XML LINQ Queries?

I have the 2 following LINQ queries and I haven't quite got my head around LINQ so what is the difference between the 2 approaches below? Is there a circumstance where one approach is better than another? ChequeDocument.Descendants("ERRORS").Where(x=>(string)x.Attribute("D") == "").Count(); (from x in ChequeDocument.Descendant...

Is there any open source software for converting SQL statements to LINQ?

Is there any open source software for converting SQL statements to LINQ? ...

Cannot implicitly convert type System.Collection.Generic.IEnumberable

I'm receiving this error in my Linq statement --- Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'hcgames.ObjectClasses.ShoppingCart.ShoppingCartCartAddon'. An explicit conversion exists (are you missing a cast?) From this query ShoppingCartItems items = Cart.GetAllItems(); ShoppingCartCartA...

LINQ to XML query returning a list of all child elements

I have got an XML document which looks something like this. <Root> <Info>....</Info> <Info>....</Info> <response>....</response> <warning>....</warning> <Info>....</Info> </Root> How can i write a LINQ to XML query so that it returns me an IEnumerable containing each child element, in this case all five child elements of , so that i c...

substring with linq??

I've got collection of words, and i wanna create collection from this collection limited to 5 chars Input: Car Collection Limited stackoverflow Output: car colle limit stack word.Substring(0,5) throws exception (length) word.Take(10) is not good idea, too... Any good ideas ?? ...

Filtering DBNull With LINQ

Why does the following query raise the error below for a row with a NULL value for barrel when I explicitly filter out those rows in the Where clause? Dim query = From row As dbDataSet.conformalRow In dbDataSet.Tables("conformal") _ Where Not IsDBNull(row.Cal) AndAlso tiCal_drop.Text = row.Cal _ AndAlso Not IsDBN...

LLBLGEN: Linq to LLBGEN don't work

I want to make custom select from the database table using Linq. We use LLBGEN as ORM solution. I can't do LINQ query to Entities Collection Class unless I call GetMulti(null) method of it. Is it possible to do LINQ query to LLBGEN without extracting all table first? BatchCollection batches = new BatchCollection(); Bat...

Using Linq to select a range of members in a list

Given a list of elements like so: int[] ia = new int[] { -4, 10, 11, 12, 13, -1, 9, 8, 7, 6, 5, 4, -2, 6, 15, 32, -5, 6, 19, 22 }; Is there an easy way in Linq to do something along the lines of "Select the elements from the -1 up to the next negative number (or the list exhausts)"? A successful result for -1...