Custom LINQ implementations
There are many LINQ implementations such as LINQ-to-Flickr. To make something like this, do I make my own custom LINQ provider? Thanks ...
There are many LINQ implementations such as LINQ-to-Flickr. To make something like this, do I make my own custom LINQ provider? Thanks ...
Hi I have a 2 tables BlogPost and BlogComments I want to get all BlogPosts that have a state of "published". and get all BlogComments for each post that has a state of "published". Im using something like this to get the blogposts: var BlogPosts = (from p in db.BlogPosts where p.State == State.Published select p).ToArray(); but due...
I have the following linq query (applied to the Northwind database) (from od in OrderDetails where od.ProductID == 11 || od.ProductID == 42 select od.OrderID).Distinct() Which gives me a list of Order Ids (67 items) where the order includes either product 11 or 42. How can I rewrite the query to give me a list of Order Ids where the o...
Hi, How do I check if two words have a common char? ex. : "word" and "letter" have common "r" "word" and "email" haven't any common chars This code is wrong because if two words have 2 common chars I get 4 in the result int numberOfCommonChars = (from c1 in word1.ToCharArray() from c2 in word2.ToCharArray(...
Hi, Im trying to use LINQ to query Objets. I'm doing the following: Dim myList As Generic.List(Of MyItem) = (From ThisItem In LinqToSqlObject.Items _ Join Folder In LinqToSqlObject.Folders _ On Folder.Id Equals Item.Id _ ...
Suppose I have the following expressions: Expression<Action<T, StringBuilder>> expr1 = (t, sb) => sb.Append(t.Name); Expression<Action<T, StringBuilder>> expr2 = (t, sb) => sb.Append(", "); Expression<Action<T, StringBuilder>> expr3 = (t, sb) => sb.Append(t.Description); I'd like to be able to compile these into a method/delegate equi...
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 = myTableAd...
var trimmed = myStringArray.Select(s => s.Substring(0, 10)); If one of the strings isn't 10 characters long I'd get an ArgumentOutOfRangeException. In this case its fairly trivial to find out and I know I can do s.Substring(0, Math.Min(10, s.Length)) With more complex object construction errors like this aren't always easy to se...
What I want to do seems pretty simple. I want to select some employers and I want to include the last 6 quarterly data records sorted by year and quarter descending. Consider the Expression: var query = from e in data.Employer.Include("EmployerQuarterly") where e.UIAccount == 22 select e; I'm on the right tra...
HI, I am trying to save some data to my .sdf file using a LinqToSql object. I have a table as follows - PersonId int not null pk forename nvarchar(4000) surname nvarchar(4000) Birthdate DateTime IsMale bit Biography nvarchar(4000) I am inserting a value into all fields apart from the PersonId column (set to identity, increment). I a...
I'm getting a timeout error when trying to execute a LINQ (-to-SQL) query System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Now, this is not just a case of a slow query: I run the equivalent SQL in SQL Management Studio and it com...
Is it possible to change a field value from inside a LINQ select query for use in an ASP.NET MVC app? For example, if a query returns a field with value "foo," I want it's output to be "bar" instead. Essentially, I want LINQ to create this TSQL statement: CREATE PROCEDURE GetSpecialCaseOfMyObject ( @param varchar(10) ) AS S...
I have a simple page I'm creating that just inserts some data from textboxes in .Net using C#. I get the overflow error stating the date must be within a specific range. The text being entered in the txtBirthdate box would be something like: 01/01/1980. When debugging, the Client1 _Birthdate object shows {1/1/1980 12:00:00}. So as far a...
In this example, an error is raised if either row.FirstName or row.LastName are NULL. How do I rewrite the Select clause, to convert a DBNull value to a blank string ""? Dim query = From row As myDataSet.myDataRow in myDataSet.Tables("MyData") _ Select row.FirstName, row.LastName NOTE: Since the DataSet is strongly-typed....
I have an XML document and I would like to sum all elements of a specific name. How do I do this? ...
I took a look at this answer and it goes in part to solving my issue. However, what I need is the following. Given I have an object; Product string code List<suitability> items and then i have this object; Suitability key value Each Product has a variable amount of [items] and the key/value pairs differ from product to pr...
We are currently using an ASP.NET project that uses Data Services and Linq. Before when the project was newly created via Wizard/Template. The generated DLL in the bin folder has the version 3.0.40818.0 but each time I rebuild the versions of the DLL reverts back into version 2.0.31005.0. I tried checking the referenced assembly and it s...
I have a problem on using LinqToSQL with paging + dynamic sorting. These are my sample code. Using db As New MyDataContext(connectionString) db.Log = new DebuggerWritter Dim result = db.User.OrderBy(Function(u) u.UserId) result = result.Skip((pageNo - 1) * pageSize).Take(pageSize) End Using This is the SQL scr...
I need to put some of the entities created via a.dbml Linq-To-Sql file into Session State. Because I am using out-of-proc State Server, they need to be serializable. How can I achieve this? I have tried setting the Serialization mode in the .dbml file to 'Unidirectional'. ...
I have the following code, that in my head should create a new row in a table: Dim fin As Boolean Dim db2 As New ChecklistModeldbmlDataContext For Each a In bServers If collection("fin" & a.ServerName) = "true, false" Or collection("fin" & a.ServerName) = "true,false" Then fin = True Else fin = False End If b...