linq-to-sql

Update a record in Linq2Sql with an object of the recordType

The following simplified code doesn't work (because it sets the retrieved object reference to the parameter), but it shows what I want to do public bool updateEvent(clubEvent newEvent) { TNightCon tCon = new TNightCon(); clubEvent cEv = (from cEvent in tCon.clubEvents where cEvent.EventID ==...

Returning a Domain Mapped List with LinqtoSql

How can I do this, ie keep the mapping separate? Instead of this: var people= (from p in db.people select new Person{ id=p.id, name=p.name }).ToList(); I want to do this: var people= (from p is...

LINQ-to-SQL and Extension method in subQuery

My extension method is: public static IEnumerable<T> FilterCultureSubQuery<T>(this Table<T> t) where T : class { return t; } I tried to use it in this query var test = from p in t.Products select new { Allo = p, Allo2 = (from pl in t.ProductLocales.FilterCultu...

Linq To SQL and Having

I am fairly new to Linq To SQL but trying to run what should be a fairly simple SQL query and can't figure out how to make it play nice in LINQ. SELECT Users.Id, Users.Id AS Expr1, Users.FirstName, Users.LastName, User_x_Territory.UserID FROM Users LEFT OUTER JOIN User_x_Territory ON User_x_Territory.UserID = U...

Implementing LINQ-to-SQL transactions through WCF

I have a WCF service which is used to add tenders to the database, which is MS SQL Server 2005. WCF uses LINQ-to-SQL. Each tender can have a lot of documents and a lot of items. The customers can add one object per service call. That is, the do something like this: TendersServiceClient service = new TenderServiceClient(); service.Begi...

When are LinqToSql Entity Id's assigned?

Are they assigned at SubmitChanges? or when a new object is created? If the latter, I would imagine there would be collisons? ...

Partial Method Inside Abstract Class (C#)

I'm creating an abstract class that can be inherited in a partial class of a LINQ to SQL class. The LINQ to SQL class contains a bunch of built-in partial methods. Is there a way that I can implement one or more of the partial methods in the abstract class? I know that partial methods can only be contained within partial classes or struc...

Too many outer joins in LINQtoSQL generated SQL

Hi, I have a question about a SQL statement generated by a LINQ2SQL query. I have two database tables (VisibleForDepartmentId is a foreign key): AssignableObject Department ---------------------- ------------ AssignableObjectId ┌────> DepartmentId AssignableObjectType │ VisibleForDepartmentId ───┘ ...

How to create a LINQ to SQL Transaction?

I have a piece of code that involves multiple inserts but need to execute submitchanges method before I finish inserting in other tables so that I can aquire an Id. I have been searching through the internet and couldnt find how to create a transaction in linq to sql. I have put comments in the code where I want the transaction to take p...

Multi-Table LinqToSql Aggregate Function

I've been having a heck of a time getting this query right, so I'm hoping that StackOverflow can point me in the right direction. I have three tables: Territories (TerritoryId, TerritoryName, etc) UserTerritories (Just a gerrund) Users (UserId, UserName, StatusId) I need to get all the Territories that have one or more Users with a ...

Serializing linq entities with WCF

I am serialzing a linq object through WCF. The dbml is setup for unidirectional serialization. My objects are pretty simple: Budget has a collection of BudgetLineItems. Each BudgetLineItem has an ItemCateogry. Budget/BudgetLineItems are serialized fine. ItemCateogry on each BudgetLineItem do not, however. I noticed by default, li...

Stop Linq To Sql from Renaming properties of the DataContext after I rename them

Hi, I got an entity called Proveedor on my Data Context. A property called Proveedors is generated for the Data Context to represent a collection of Proveedor. I rename it to Proveedores which is the correct spelling in spanish. But as soon as i do anything on the model (not related to the Proveedor Entity) and rebuild it renames it bac...

Trouble with jQuery MaskMoney plugin and Field type Decimal (SQL SERVER table)

Hi people. I am using a ASP.NET MVC framework, jQuery library (1.3.2), linq to sql, sql server 2005. I have a problem with jQuery MaskMoney plugin, to save data in sql server table. I created a table, where this table have a field "valueProducts" type Decimal(18,2). In my page, I have a html field with jQuery maskmoney. Example: 10.00...

Transferring LINQ data objects

I am working on a webservice where we use LINQ-to-SQL for our database abstraction. When clients use our webservice, the objects are serialized to XML and all is dandy. Now we wish to develop our own client that uses the native data types since there's no reason to do objects->xml->objects. However, from what I understand you can't tran...

DBLinq not generating where clause

I'm testing out DBLinq-0.18 and DBLinq from SVN Trunk with MySQL and Postgresql. I'm only using a very simple query but on both database DBLinq is not generating a Where clause. I have confirmed this by turning on statement logging on Postgresql to check exactly what request DBLinq is sending. My Linq query is: MyDB db = new MyDB(new N...

What's the best method to stop duplicate inserts into the database

I have a forum application using asp.net, c#, sql server and linq to sql. It suffers from multiple inserts, I think when the insert button is pressed but also maybe when the browser is refreshed or back is clicked. What's the most comprehensive way, or ways to prevent this. UPDATE: I currently use response.redirect after inserting text...

Introduction to database interaction with C#

Up to now in my programming career (two years) I have not had much database experience, but the company where I now work uses databases extensively for their product, and I feel behind the curve. So I would like to know how best to start learning database interaction with C#. I've read about LINQ-to-SQL and ADO.net. Are these the right ...

WPF Data Access Layer Architecture

I am currently developing a WPF client application which uses Linq-to-SQL for the typed table objects and to wrap around an abundance of CRUD stored procedures in a MS SQL database on an external server. I do not foresee manipulating data directly via the context, only the stored procedures. My two biggest concerns are: 1) Database secu...

dont understand this exception

im using linq to sql i have a Mission entity, which holds a collection of assignments. lets say i went to query the total duration of all the assignments per mission. and i've written the following query: return db.Missions.Select(m => new MissionNameDays() { Name = m.MissionName, Days = m.Assignments.Sum(a => a.Du...

Linq2Sql Pipes and Filters on inner list object

I'm using Linq2Sql with pipes/filters. My database consists of Accounts and Transactions tables where each Transaction row is linked to an Account. When displaying an Account I want to show the Account with all its Transactions. Simple enough. Now I am trying to limit the transactions that are shown by /accounts/4/{year}/{month}/{day} f...