linq-to-dataset

Linq for sum of distinct addresses

こ雲淡風輕ζ 提交于 2019-12-25 18:39:01
问题 I have a DataTable of Products. Each product has a weight and a return address. The return address is comprised of 7 fields. I need to cycle through the distinct addresses and sum up the total weight of product. Example table would look like this... Product weight address1 address2 address3 city state postcode country A123 6 House 1st Street some place a city a state AB1 2CD GB A456 3 House 1st Street some place a city a state AB1 2CD GB A789 4 House 1st Street some place a city a state AB1

Update/Insert to a table using SQLCeResultSet

心已入冬 提交于 2019-12-20 21:02:14
问题 I have a SQL Compact Edition Database that I update periodically (via web services). The part where I write to the database is taking way too long. I am currently doing it with Linq to Datasets (as seen in this question). I have heard that if I do it with with SQLCeResultSet that it will work faster. So, given that I have a table like this: tblClient +- CLIENT_ID {Unique identifier} (Primary Key) +- CLIENT_NAME {varchar (100)} +- CLIENT_ACTIVE {bit} And I have it in object that I get from my

How to join with LinQ to (typed) dataset?

假装没事ソ 提交于 2019-12-18 17:25:32
问题 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

Join in LINQ that avoids explicitly naming properties in “new {}”?

安稳与你 提交于 2019-12-12 10:39:22
问题 I would like to do something like this: DataTable q = from c in customers join o in orders on c.Key equals o.Key into outer from j in outer.DefaultIfEmpty() select new { c.*, j.* }; The closest I currently got is the following: var q = from c in customers join o in orders on c.Key equals o.Key into outer from j in outer.DefaultIfEmpty() select new { c, j }; I'd like my result (q) to have all the columns from c and j. both c and j contain a lot of columns, so I'd rather not list them as such:

Slow Update/insert into SQL Server CE using LinqToDatasets

拥有回忆 提交于 2019-12-11 16:04:45
问题 I have a mobile app that is using LinqToDatasets to update/insert into a SQL Server CE 3.5 File. My Code looks like this: // All the MyClass Updates MyTableAdapter myTableAdapter = new MyTableAdapter(); foreach (MyClassToInsert myClass in updates.MyClassChanges) { // Update the row if it is already there int result = myTableAdapter.Update(myClass.FirstColumn, myClass.SecondColumn, myClass.FirstColumn); // If the row was not there then insert it. if (result == 0) { myTableAdapter.Insert

LINQ casting with a Data.DataTableCollection

走远了吗. 提交于 2019-12-11 06:36:24
问题 I have the following VB.NET code that I am using to sort a Data.DataTable by column count. For Each dtTarget As Data.DataTable In _ From x In Target.Tables _ Where DirectCast(x, Data.DataTable).Rows.Count > 0 _ Order By DirectCast(x, Data.DataTable).Columns.Count ... Next Is there a way to indicate that x is a Data.DataTable without having to DirectCast it each time it is referenced (twice in this case) in the LINQ query? 回答1: Something like: Target.Tables.Cast<Data.DataTable>() and then make

Search DataTable with values from another table

穿精又带淫゛_ 提交于 2019-12-11 05:19:36
问题 I'm trying to search one DataTable with values from another DataTable using LINQ, but no progress so far... How to do it? In example below i have table , in which i search, and PlTable , which has only one column; and i need to retrieve every row from table , in which the Name field contains at least one string of Name field in PlTable 's rows. Dim ePlTable As IEnumerable(Of DataRow) = PlTable.AsEnumerable() Dim found = From row In table.AsEnumerable Where row(0).Contains(ePlTable) Select row

LINQ - How can I use DataSet.DataRelation to join these tables and sum one field?

与世无争的帅哥 提交于 2019-12-11 04:49:47
问题 My LINQ query is not producing the expected output below. Basically, it's the sum of table3.cost corresponding to table2.code and table2.class categorized by table1.alias and ordered by table1.priority. I added two DataRelation's to the DataSet: ds.Relations.Add("Table1Table2", ds.Tables[1].Columns("ID"), ds.Tables[2].Columns("ParentID"); ds.Relations.Add("Table2Table3", new DataColumn[] { ds.Tables[2].Columns["Code"], ds.Tables[2].Columns["Class"] }, new DataColumn[] { ds.Tables[3].Columns[

select column from dataset using LINQ

和自甴很熟 提交于 2019-12-10 22:27:13
问题 I am absolutely new to linq query, please help with this query, dataset has fields: Name Value Client_owner. I want to select Value if name == "searchtext" DataTable results = (from d in ((DataSet)_MyDataset).Tables["Records"].AsEnumerable() orderby d.Field<string>("Name") ascending where d["Name"].ToString().ToLower().Contains(ProjectName.ToLower()) select d??).CopyToDataTable(); 回答1: var query = (from d in _MyDataset.Tables["Records"].AsEnumerable() where d.Field<String>("Name").Equals(

LINQ-Join tables on nullable columns

瘦欲@ 提交于 2019-12-10 17:26:53
问题 how to JOIN tables on nullable columns? I have following LINQ-query, RMA.fiCharge can be NULL: Dim query = From charge In Services.dsERP.ERP_Charge _ Join rma In Services.dsRMA.RMA _ On charge.idCharge Equals rma.fiCharge _ Where rma.IMEI = imei Select charge.idCharge I get a "Conversion from type 'DBNull' to type 'Integer' is not valid" in query.ToArray() : Dim filter = _ String.Format(Services.dsERP.ERP_Charge.idChargeColumn.ColumnName & " IN({0})", String.Join(",", query.ToArray)) So i