The following bit of L2S code is giving me this very odd stack trace. If I attach a debugger and set a breakpoint on top of this debugger, it looks like the issue lies in evaluating transactions.Count(). Can anyone see specifically what would be causing this? Note that there are not rows in the Transactions table that fall in to this whe...
I have a table Site in SQL with (amongst others) three properties idReviewer1, idReviewer2, idReviewer3. Now I would like to create a methods on the entity class of Site to check if a user is a reviewer:
partial class Site
{
public bool IsReviewer(int idUser)
{
return idReviewer1 == idUser || idReviewer2 == idUser || i...
Problem happening when two users at the same time try to Submit CHanges to the datacontext.
Datacontext are in the HTTPContext so they are not being shared
PLEASE HELP
...
class Test {
int Id{get;set;}
string Name {get;set;}
string Description {get;set;}
}
//1)ok
context.Tests.Select(t => new {t.Id, t.Name}).ToList().Select(t => new Test{Id = t.Id,
Name = t.Name});
//2)ok
class TestPart{
int Id{get;set;}
string Name {get;set;}
}
context.Tests.Select(t => new TestPart{Id = t.Id,
Name = t.Name...
I am building a c# - linq - sql server winforms/asp.net application, accessing a database. I would like my business logic layer to be easily testable, and that means not littering it with Linq database queries everywhere. What design patterns/ best practices are available for the following use cases
- inserting/updating a new object
- s...
Hello,
I'm having some troubles with updating linq to sql entities.
For some reason, I can update every single field of my item entity besides name.
Here are two simple tests I wrote:
[TestMethod]
public void TestUpdateName( ) {
using ( var context = new SimoneDataContext( ) ) {
Item item = context...
This code is a no-go
var errors = (from error in db.ELMAH_Error
select new
{
error.Application,
error.Host,
error.Type,
error.Source,
error.Message,
error.User,
error.StatusCode,
error.TimeUtc
}).ToList();
...
Without hiding the Child object's reference to the Parent object, has anyone been able to use an XmlSerializer() object to move a Linq to SQL object to an XML document, or is the only appropriate way of handling this to create a custom serialization/deserialization class to handle moving the data to/from the xml document?
I don't like t...
OK so I've got 2 tables for this instance, Users{UserID, Name}, Company{CompanyID, UserID, Name, Payrate}
i also have 2 combo boxes, first one is for Users which Displays Name, and the Value is UserID
i need the second combobox to get the Names from the Company table, but only showing Companies that are relevant to the selected user. I ...
How can I update an existing LINQ entity?
This code gives me: "Cannot insert an entity that already exists."
Any better practises on updating/inserting with linq?
foreach (ListViewItem lvi in lvStudents.Items)
{
HiddenField hfStudentID = lvi.FindControl("hfID") as HiddenField;
CheckBox cbPresent = lv...
I am encountering a problem when using LINQ in C#, I am constantly getting "Specified cast is not valid". This is what I am trying to do.
I create a class in which I declare all the columns of the table.
[Table(Name="tbl_Aff")]
public class Affiliate
{
[Column]
public string name;
[Column]
...
I'm using asp.net mvc, linq2sql, iis7 and sqlserver express 2008.
I get these intermittent server errors, primary key conflicts on insertion. I'm using a different setup on my development computer so I can't debug. After a while they go away. Restarting iis helps. I'm getting the feeling there is cache somewhere that I'm not aware of. C...
I have recently linked a database to my C# service by creating a LINQ to SQL item in my solution. Everything was fine and dandy as I was continuing to code, but then I suddenly noticed that there where 16 Ambiguity errors. e.g.
Ambiguity between 'EmailService.Properties.Settings.defaultInstance' and 'EmailService.Properties.Settings.d...
Hi,
I am porting an existing application from Linq to SQL to Entity Framework 4 (default code generation).
One difference I noticed between the two is that a foreign key property are not updated when resetting the object reference. Now I need to decide how to deal with this.
For example supposing you have two entity types, Company and...
I am in a process of rewriting an old web application to WPF application.The other parts(which other team members handles) of the project is using LINQ to SQL for handling data access.The old application was using some stored procedures which has several updates statement(to many tables).some stored procedures even have cursors running i...
I'm querying a view and filtering the results with a column named status. I'd like to query it so I can search for rows with different status, by using the IN operator as I'd do in SQL.
As so:
SELECT * FROM VIEW WHERE Status in ('....', '.....')
How can I achieve this?
...
Using LINQ 2SQL , How can i call a stored procedure which returns either 1 or 0 when being executed.My procedure has 3 input params.I want to know the return value from procedure in my code too.
...
How can I use Linq-to-sql to a search like this:
where obj.id equals any of the following {1,2,3,4}
I would guess I could use the in or perhaps contains?
where obj.id in Enumerable.Range( (int) myEnum.Start, (int) myEnum.End) ) ?
...
I have the code below where I am trying to go through the child questions of my qestAires anonymous type. When I get to the foreach loop i get the error:
foreach statement cannot operate on
variables of type 'Question' because
'Question' does not contain a public
definition for 'GetEnumerator'
What do I need to do differentl...
I am returning two lists from the database using LINQ to SQL compiled query.
While looping the first list I remove duplicates from the second list as I dont want to process already existing objects again.
eg.
//oldCustomers is a List<Customer> returned by my Compiled Linq to SQL Statmenet that I have added a .ToList() at the end to
/...