linq

T-SQL Operators LIKE need help

i would like to search in DB input string is "oxoşil" o -> [o-ö] x -> [x-ks] ş -> [s-ş] ş -> [ş-sh] i need to search all of these cominations. Needed finally search criteria is [o-ö][x-ks][o-ö][ş-s-sh][i-ı]l is there any way to to this with t-sql like operator? or in linq? ...

Linq to datasets - getting specific column value in C#

i'm trying to get an error description according to error Id: String errorDesc = from resultCodesTableRow in resultCodesDT.AsEnumerable() where resultCodesTableRow.Field<int>("Error_Code_Column_Name") == errorCode select resultCodesTableRow.Field<string>("Error_Desc_Column_Name").T...

linq to datasets - get a specific datarow

i have a table with these columns: errorCode (int) errorDesc (Varchar) i'm trying to get the datarow where errorCode is 5: DataRow resultCodeRow = (from resultCodesTableRow in resultCodesDT.AsEnumerable() where resultCodesTableRow.Field<int>("result_Code_colum_Name") == 5 ...

LINQ: Select a collection?

I'm trying to use LINQ: IEnumerable<String> debtors = (from expense in CurrentExpenses where expense.WhoPaid == username select expense.WhoOwes.AsEnumerable()).Distinct(); (username and WhoPaid are strings, WhoOwes is ICollection<String>) What I want to do is get an IEnume...

LINQ: Dealing with anonymous types

I'm trying to generate a chart of the form: User A User B Owes Owed Net Sam David $20 $10 $10 Timbo ODP $30 $0 $30 Using the following query: var debt = from user in users select new { Username = username, ...

Silverlight: Empty Data Grid

I'm trying to fill a DataGrid with an anonymous type generated by a LINQ query. When I put the query results in a list box, it appears fine. However, when I put the query results in a data grid, the correct number of rows are generated, but the cells are empty. (The data grid is on the left, with the list box on the right.) Assigning...

Is there a 3rd party library that knows to convert a linq expression to a human readable string representation?

I have a linq expression and I wish to display it in the log in a human readable form. Any one knows any library that can do it? I saw this entry http://stackoverflow.com/questions/3294438/creating-a-string-from-a-lambda-expression, but it is not that useful, in my opinion. Thanks. EDIT Now that I think about it, my case is probably n...

Partial Matches in a String[]

I have two string arrays; one is list and the other is find I want to be able to count the number of items in find that are partially contained within 'list' using extension methods and linq. Here is a summary of how I would do it within a few nested loops: int Count = 0; foreach (string f in find) { foreach (string l in list) ...

How to convert a query consisting of INNER JOIN, LEFT JOIN and GROUP BY to a similar linq2sql query?

I'm trying to convert the following T-SQL query to linq2sql one. Whatever I do, it translates it to some nasty stuff with cross joins. Any suggestion? Given tables A, B, C SELECT A.Id, A.Name, Pool.Total FROM A INNER JOIN B ON A.Id = B.AId LEFT JOIN ( SELECT AId, SUM(Quantity) as Total FROM C GROUP BY AId) AS Pool ON A.Id = C.AId WHER...

linq combining 2 queries

Let's say I have 3 tables: carts, baskets and eggs where a basket can contain many eggs and where carts contain many baskets. Each basket has a foreign key that maps to a cart and each egg has a foreign key that maps to a basket. I need to return a table that contains these 3 columns: Cart Name | Count of Baskets in Cart | Count of Egg...

Help troubleshooting LINQ query

I have this LINQ query: var returnList = from TblItemEntity item in itemList join TblClientEntity client in clientList on item.ClientNo equals client.ClientNumber join TblJobEntity job in jobList on item.JobNo equals job.JobNo where...

C#/LINQ: How to Query this XML Structure

I am trying to get the value of <getthis> but can't seem to get just the string value. I think this is quite simple but I can't seem to get it. I am trying to do it with LINQ XML <?xml version="1.0" encoding="utf-8"?> <root> <item> <name></name> <title></title> </item> <info> <getthis>value here</get...

c# linq conditional union

hi I have the following code and would like to only make each union if a condition is true. I Know I could write a select of if else but wanted to know if there is a slicker Linq way!? //join the list into one and sort by seqnumber SegmentList = Alist.Cast<BaseSegment>() .Union(BList.Cast<BaseSegment>()).Union(CList.C...

Collection of X elements, want to traverse them in groups of two (using Linq?)

I have a collection of say 8 elements. I want to traverse it in such a way, that after 2 iterations I do something else, and then back to traversing. A practical application is making a layout. I lay two square boxes, then I print a new line, and then I lay two square boxes. is there a way I can make a sequence collection into somethin...

How can i join Master-Detail-Detail Tables with Linq in Entity Framework

I have 3 table a,b and c a.Id,a.code /master b.Id.b.code,b.aId,c.Id /detail c.Id,c.code / detail of detail i will join this three table with linq and show it in grid. How can i do this? ...

How to use a dictionary property in C# using LINQ

While I userstand how get; & set; with simple types such as strings now can more properties like Dictionary be get or set or can they? I have a small dos programe trying to do this. snippet below. # User.cs namespace LDIFMod { public class User { public string UserHash { get; set; } public string UserID { get; ...

Linq-to-SQL: Use a shared transaction between LinqDataSource and DataContext?

Hello all, I have a page where I use two ASP DetailsView controls to render data from two different, but related, LinqDataSource objects. My primary table is represented in the first DetailsView/LinqDataSource set, and I use the LinqDataSource's built-in update functionality to persist changes when the DetailsView is in edit mode. The p...

Observable<string> updated events?

I'm just trying to do a simple event handler on a string variable, so that if the string changes, it will do a Console.WriteLine (using the new Reactive library from MS (Rx)) The issue that I have is that it will display the first bit when I instantiate the class ("RandomGuid : Mine?"), but after that, none of the stuff I change after...

Combine object properties into a list with LINQ

Say I have properties num1, num2, num3 on objectX. I want to take a list of objectX and create a single list of integers populated with the num1, num2, num3 values. Here's an example using System.Drawing.Point: Point p1 = new Point(1,2); Point p2 = new Point(3,4); var points = new[] { p1, p2 }; var combined = points.SelectMany(a => n...

from datatable to array، no loop

Following Code for transmission to the list box is : DataTable dt = new DataTable(); DataColumn dc = new DataColumn("BestSite", typeof(string)); dt.Columns.Add(dc); for (int i = 1; i <= 10; i++) { DataRow dr = dt.NewRow(); dr[0] = i.ToString() + " = stackoverflow"; ...