I have a simple lambda expression which runs fine as a UNIT test and also runs fine when I copy the code into the Main method of my application. However, when I run the same piece of code within a callback method (via JMS courier) I get the above error. Has anyone encountered this?
Example code failing:
Expression<Func<JupiterDividend,...
I have 2 classes with a LINQ association between them i.e.:
Table1: Table2:
ID ID
Name Description
ForiegnID
The association here is between Table1.ID -> Table2.ForiegnID
I need to be able to change the value of Table2.ForiegnID, however I can't and think it is because of the association (as wh...
I'm running into a mental roadblock here and I'm hoping that I'm missing something obvious.
Anyway, assume I have a table that looks like this:
ID LookupValue SortOrder
============================================
1 A 1000
2 B 2000
3 B ...
I'd like to do the equivalent of the following in LINQ, but I can't figure out how:
IEnumerable<Item> items = GetItems();
items.ForEach(i => i.DoStuff());
What is the real syntax?
...
In a LINQ to SQL class, why are the properties that are created from the foreign keys EntitySet objects, which implement IEnumerable, where as the objects on the DataContext are Table objects which implement IQueryable?
EDIT: To clarify, here is an example that illustrates what I'm trying to understand. This example:
ctx.Matches.Where(...
When creating a new object that is mapped to one of my SQL Server tables, LINQ inserts a new record into the table when I call SubmitChanges. I want to prevent this, but still need my new object.
I know about the custom methods, but is there anyway to disable this behaviour so that it just updates existing records and never inserts new...
I'm trying to decide on the best strategy for accessing the database. I understand that this is a generic question and there's no a single good answer, but I will provide some guidelines on what I'm looking for.
The last year we have been using our own persistence framework, that although limited has server as well. However it needs some...
I have these two pieces of code, wich one is more readable?
foreach
decimal technicalPremium = 0;
foreach (Risk risk in risks)
{
technicalPremium = technicalPremium + risk.TechnicalPremium;
}
return technicalPremium;
linq
return risks.Sum(risk => risk.TechnicalPremium);
...
I have an SQL Server DB with a table with these fields:
A bit with the default value 1, NOT NULL.
A smalldatetime with the default value gettime(), NOT NULL.
An int with no default value, IDENTITY, NOT NULL.
When I generate Linq to SQL for this table, the following happens:
The bit is given no special treatment.
The smalldatetime i...
I just asked this question. Which lead me to a new question :)
Up until this point, I have used the following pattern of selecting stuff with Linq to SQL, with the purpose of being able to handle 0 "rows" returned by the query:
var person = (from p in [DataContextObject].Persons
where p.PersonsID == 1
select...
I have some hierarchical data - each entry has an id and a (nullable) parent entry id.
I want to retrieve all entries in the tree under a given entry. This is in a SQL Server 2005 database. I am querying it with LINQ to SQL in C# 3.5.
LINQ to SQL does not support Common Table Expressions directly. My choices are to assemble the data in ...
Hi.
I use linq To Objects instructions on an ordered array.
Which operations shouldn't I do to be sure the order of the array is not changed?
...
I'm trying to start using LINQ and specifically LINQ to SQL but I'm having some difficulties
I've tried this with SqlMetal and now using the database table designer in Visual Studio and I keep getting similar errors, like in this code, using the data context I created with the database layout designer in VS2008.
using System;
using Sys...
If I query a table with a condition on the key field as in:
var user = from u in dc.Users
where u.UserName == usn
select u;
I know that I will either get zero results or one result. Should I still go ahead and retrieve the results using a for-each or is there another preferred way to handl...
Sorry, that title just hurts. I'm wondering if there is a Linq to collections extension method that collapses the following code segment into a single line:
public IEnumerable<Child> GetAllChildren(IEnumerable<Parent> parents){
var result = new List<Child>();
foreach(Parent parent in parents)
foreach(Child child in parent.Chi...
I've been struggling with a problem for the past couple days and haven't found a solution.
I have an Visual Studio solution with 2 projects, the first one is a DLL with my business objects and logic, the other project is my WinForm application, and a reference dependency on the first project.
I initially wrote the business objects with...
Is there any reason something like this would not work?
This is the logic I have used many times to update a record in a table with LINQ
DataClasses1DataContext db = new DataClasses1DataContext();
User updateUser = db.Users.Single(e => e.user == user);
updateUser.InUse = !updateUser.InUse;
db.Log = new System.IO.StreamWriter(@"c:\t...
What is the purpose of this UnaryExpression, and how should it be used?
...
I'm playing a bit with LINQ to SQL and overall it's a much better option than what Microsoft had before (DataSet), but it seems that object-oriented capabilities are still limited. Since we currently use a custom persistence framework that created a OO model on top of DataSet, I'm looking to port the framework to a new version building a...
I have an ASP.NET site that has been running perfectly for a long time, nothing's changed recently. From one hour to the next I started receiving an IndexOutOfRangeException in a line where I do a LINQ query like this:
var form = SqlDB.GetTable<ORMB.Form, CDB>()
.Where(f => f.FormID == formID)
.Single();
ORMB.Form is a POCO ob...