linq

LINQ to Dataset DBNULL problem / null reference exception

I have the following LINQ query which always results in an error when my "Remark" column in dtblDetail is null, even though I test if it is NULL. var varActiveAndUsedElementsWithDetails = from e in dtblElements join d in dtblDetails on e.PK equals d.FK into set from...

Group by Question in Linq

I am having a problem with LINQ and I was hoping someone could explain to me why. I have this code: List<Spec> specs = GetSpecs(userObject, seasonID, partnershipID); var query = from s in specs where (DateTime)s.FinalApprovedDate != null && !((DateTime)s.FinalApprovedDate).Equals...

converting group SQL expression into LINQ

Hi guys! I am having a real pain in converting this query expression into my LINQ expression. SELECT r.Disc_code ,r.SEX FROM RACE r WHERE r.EVENT_CODE = 100 GROUP BY r.SEX , r.disc_Code order by r.disc_code i can work with one table but i have not seen any example which chains two group expressions in stackove...

Cleaning up a simple foreach with linq

The following method is pretty simple, I'm trying to determine a line-item rate by matching up another property of the line-item with a lookup from a parent object. There's a few things I don't like about it and am looking for elegant solutions to either make the method smaller, more efficient, or both. It works in it's current state a...

Linq insert on primary key field that is autosync

I more or less want to do what this question suggests. http://stackoverflow.com/questions/507515/how-do-i-manually-set-an-identity-field-in-linq-to-sql-identity-insert However, I want to explain. I have a client db. I load Linq objects from here and the send them across WCF. On the other side, I attach them to a data context and post th...

LINQ and Devexpress Grid Datasource

I have a DevExpress grid (DevExpress.XtraGrid.GridControl 8.2) with a datasource set at runtime like so: private DataContext db = new DataContext("connection string"); gridControl.DataSource = from t in db.sometable select new { Field1 = t.Name, ...

Perform .Select() on IQueryable with List of Func<T, string> delegates.

First of all, let me apologize in case the title doesn't make sense. I'm having a hard time understanding what I'm doing, let alone being able to use the right words for describing what I'm doing. I'm building a generic grid class in which I define the columns by a header / linq expression combination: public class Column<T> { publ...

Linq Stored Procedure Issue

HI all, I'm having an issue with Linq and my stored procedures. The error I am getting is : Could not find an implementation of the query pattern for source type 'int'. 'Select' not found. Here is the code found in my DBClasses: [Function(Name="dbo.findahostel_getHostelsByTags")] public IEnumerable<hostel> findahostel_getHostelsB...

How to Re-Order Evaluation of this Linq Scenario

Here is a code snippet IEnumerable<Car> GetCars() { foreach(var request in RequestQueue()) { RemoveFromQueue(request); yield return MakeCar(request);//Expensive } } //Usage Scenario 1: No Problem foreach(Car c in GetCars()) { //Do stuff } //Usage Scenario 2: Problem, I have constructed all cars, but want o...

What is the linq query that would replace my two foreach

Hi! I'm struggeling to figure out how to replace the two foreach below. public void UpdateChangedRows(List<Row> changedRows) { // How to write linq to update the rows (example code using foreach) foreach (Row row in table.Rows) { foreach (Row changedRow in changedRows) { ...

Advanced level VB.NET Book Recommendation with good Lambda Expressions and LINQ chapters

I'm looking for an advanced level VB.NET book which covers LINQ and Lambda Expressions. Generally I read C# .NET books due to lack of good VB.NET books when it comes to generic .NET Framework related subjects. However Lambda and LINQ is quite different in C# and VB.NET I'm looking for an advanced level VB.NET book on this subject. Any ...

List of unique strings in database table using Linq?

I have a "Tickets" table with somewhat following structure (removed unnecessary columns) int | string | int | ID | Window | Count | ------------------------ 0 | Internet | 10 | 1 | Phone | 20 | 2 | Fax | 15 | 3 | Fax | 10 | 4 | Internet | 5 | . | . | . | . | . | . ...

Convert Func<T, string>[] into Func<T, string[]> ?

Consider this class: public class Column<T> { public string Header { get; set; } public Func<T, string> ValueExpression { get; set; } } used like this: var columns = new List<Column<Employee>> { new Column<Employee> {Header = "Employee Id", ValueExpression = e => e.EmployeeID.ToString()}, ...

When is OnValidate called in Linq?

I want to implement this partial method in my Linq table class. partial void OnValidate(System.Data.Linq.ChangeAction action); My hope is that is it called right before an insert. Can anyone tell me when the OnValidate method is called? Update 1 I understand that I can check the enum to see what action causes it to fire. But WHEN d...

Linq to SQL

Possible Duplicates: Is LINQ to SQL DOA? I am starting a new ASP.Net project which holds all data in a SQL database. I would normally use Linq to SQL to do all my queries, updates and inserts. but as i recently found out Microsoft will no longer develop/support Linq to SQL. What would you use as an alternative? Does anyone know...

Connection string in WCF with LINQ, C#, VS2008

I added a DBML file with the appropriate connection string and valid credentials. I logged of my VPN hosting the SQL server and I wanted to test my WCF service in terms of what errors would be raised if it could not find the DB. public List<Users> GetName(strinng UserEmail) { var dbResult = from u in Users where u.em...

better way of linq multiple joins?

Hello, Here is what I am trying to do: I have three tables, manifest, details and billingJournal for each manifest there are details and may be a billingJournal entry or not, if there is and it has the field recordType = 1 then billingJournal.amount is the billing amount and I need it in my grid also. I currently am doing a two step ...

Convert SQL Query back to Linq Expression programmatically

Is it possible to somehow programmatically convert a sql query to a linq expression tree? The sql query is supposed to be generated by this linq query, so I'm thinking of it as a poor man's serialization\deserialization of linq queries to t-sql format. Thank you. ...

How to send Linq data class via WCF and bind input control with this class property?

For strongly-typed & type-safe solution, I have to do the following step. Create some Silverlight application. Binding input control to Linq data class. Validate data by using rule from attribute of data class. Send data to server via WCF. But, I have some question. How to bind input control with linq data class property? How to d...

Can i do this with dynamic LInq or is there a better way - Linq, C#, VS2008

This is my static query var results = from v in users join d in orders on v.UserId equals d.UserId join p in Products on d.ProductId equals p.ProductId where v.UserName.Contains(UserName) where v.FirstName.Equals(FirstName) where v.ZipCity.Equals(ZipCity) ...