linq-to-dataset

Get duplicates for two columns with LINQ

本秂侑毒 提交于 2019-12-10 15:31:22
问题 LINQ drives me crazy. Why does following query not return the duplicates, whereas it works with only one identifier? Where is my error? ' generate some test-data ' Dim source As New DataTable source.Columns.Add(New DataColumn("RowNumber", GetType(Int32))) source.Columns.Add(New DataColumn("Value1", GetType(Int32))) source.Columns.Add(New DataColumn("Value2", GetType(Int32))) source.Columns.Add(New DataColumn("Text", GetType(String))) Dim rnd As New Random() For i As Int32 = 1 To 100 Dim

Left Outer Join - LINQ to Datatable

淺唱寂寞╮ 提交于 2019-12-07 17:28:12
问题 I'm trying to apply a left outer join using LINQ on two data tables. I'm receiving the exception listed below when I try to debug and view data contained in result variable: System.ArgumentException: Value cannot be null. Parameter name: row Code: private DataTable DataTable1() { DataRow dataRow = null; DataTable dt1 = new DataTable(); dt1.Columns.Add("EmpId"); dt1.Columns.Add("EmpName"); dataRow = dt1.NewRow(); dataRow["EmpId"] = "EMP001"; dataRow["EmpName"] = "Ajaj Kumar"; dt1.Rows.Add

Is LINQ to Dataset subset of LINQ to EF or these two are independent?

此生再无相见时 提交于 2019-12-07 09:33:40
问题 Is LINQ to Dataset subset of LINQ to EF or these two are independent? 回答1: Linq works with the concept of queryProviders. The query provider is responsible for translating the lamba expressions into queries on the underlying data store. as Obalix said before me Linq to Entities query provider translates the linq with lambdas into real sql which is executed using underlying ado.net objects. Take a look at canonical functions here, which are translated into sql (and take notice which are not).

Why doesn't EnumerableRowCollection<DataRow>.Select() compile like this?

点点圈 提交于 2019-12-07 08:17:37
问题 This works: from x in table.AsEnumerable() where x.Field<string>("something") == "value" select x.Field<decimal>("decimalfield"); but, this does not: from x in table.AsEnumerable() .Where(y=>y.Field<string>("something") == "value") .Select(y=>y.Field<decimal>("decimalfield")); I also tried: from x in table.AsEnumerable() .Where(y=>y.Field<string>("something") == "value") .Select(y=>new { name = y.Field<decimal>("decimalfield") }); Looking at the two overloads of the .Select() method, I

Left Outer Join - LINQ to Datatable

倖福魔咒の 提交于 2019-12-05 21:35:46
I'm trying to apply a left outer join using LINQ on two data tables. I'm receiving the exception listed below when I try to debug and view data contained in result variable: System.ArgumentException: Value cannot be null. Parameter name: row Code: private DataTable DataTable1() { DataRow dataRow = null; DataTable dt1 = new DataTable(); dt1.Columns.Add("EmpId"); dt1.Columns.Add("EmpName"); dataRow = dt1.NewRow(); dataRow["EmpId"] = "EMP001"; dataRow["EmpName"] = "Ajaj Kumar"; dt1.Rows.Add(dataRow); dataRow = dt1.NewRow(); dataRow["EmpId"] = "EMP002"; dataRow["EmpName"] = "Sanjay Gupta"; dt1

Is LINQ to Dataset subset of LINQ to EF or these two are independent?

醉酒当歌 提交于 2019-12-05 18:16:40
Is LINQ to Dataset subset of LINQ to EF or these two are independent? Linq works with the concept of queryProviders. The query provider is responsible for translating the lamba expressions into queries on the underlying data store. as Obalix said before me Linq to Entities query provider translates the linq with lambdas into real sql which is executed using underlying ado.net objects. Take a look at canonical functions here , which are translated into sql (and take notice which are not). On the other hand linq to dataset works against DAtaSet infrastructure. As you may remember Data Set has

Aggregate datatable with dynamic number of columns

末鹿安然 提交于 2019-12-01 14:36:56
I have a datatable with dynamic set of columns and want to aggregate the numeric based columns and keep the final rows into new datatable. DataTable Sample:- PartnerName CreditCol DebitCol AmountCol .... P1 10 20 30 P2 1 2 3 P3 3 1 10 P2 1 100 200 The desired output should be :- PartnerName CreditCol DebitCol AmountCol .... P1 10 20 30 P2 2 102 203 P3 3 1 10 The main thing here is the column set and will be dynamic . Sometime, there could be two columns and sometimes it could be 20 cols. Please suggest the linq query or any other solution. Here is a dynamic approach that should work for your

Store an image in a SQL Server CE database

☆樱花仙子☆ 提交于 2019-11-30 20:59:23
Does any one know of an example on how to store an image in a SQL Server CE database? What data type should the column be? (I am guessing binary.) I use Linq-To-Datasets. Is it possible using that to put the image into the database and pull it out again later? Thanks for any advice. Here is how I did it: MemoryStream stream = new MemoryStream(); myBitmapImage.Save(stream, ImageFormat.Png); myInsertLinqToDataSetRow.IMAGE_COLUMN = stream.ToArray(); To load it back out again I did this: MemoryStream stream = new MemoryStream(myLinqToDataSetRow.IMAGE_COLUMN); myBitmapImage.SignatureImage = new

How to join with LinQ to (typed) dataset?

拈花ヽ惹草 提交于 2019-11-30 15:36:56
i recently upgraded VS 2005 to 2010 and am fairly new to LinQ. Maybe somebody can put me in the right way. Background : I have a typed dataset and have the standard SQLMembershipProvider extended with a Table AccessRule. So a role can have infinitely AccessRules(f.e. "Administrator" has "DeleteCustomer"). I use a custom membership provider that inherits from SqlMemberShipProvider and has an overloaded function hasAccess(one with a memory-dataset as parameter and the other uses the database directly). This is the complete Model: Now i need to know f.e. if a User with UserID= '89f9ea8d-8ae1-460b

Store an image in a SQL Server CE database

两盒软妹~` 提交于 2019-11-30 05:44:28
问题 Does any one know of an example on how to store an image in a SQL Server CE database? What data type should the column be? (I am guessing binary.) I use Linq-To-Datasets. Is it possible using that to put the image into the database and pull it out again later? Thanks for any advice. Here is how I did it: MemoryStream stream = new MemoryStream(); myBitmapImage.Save(stream, ImageFormat.Png); myInsertLinqToDataSetRow.IMAGE_COLUMN = stream.ToArray(); To load it back out again I did this: