linq-to-sql

Attach an entity that is not new, perhaps having been loaded from another DataContext. LINQ to SQL - not reproducible

Alright How I got this error I got one application sitting on a server (asp.net) 2 users accessing this application - doing some bulk data processing . eg. entering values and then the application is working with another system to extract values for them and then saving. I can't recreate the error The error logs show: The error ha...

LinqKit stack overflow exception using predicate builder

I am writing an application in C# using LINQ and LINQKit. I have a very large database table with company registration numbers in it. I want to do a LINQ query which will produce the equivalent SQL: select * from table1 where regno in('123','456') The 'in' clause may have thousands of terms. First I get the company registration numbers...

LINQ to SQL left outer joins

Is this query equivalent to a LEFT OUTER join? var rows = from a in query join s in context.ViewSiteinAdvise on a.Id equals s.SiteInAdviseId where a.Order == s.Order select new {....}; I tried this but it did not result from s in ViewSiteinAdvise join q in query on s.SiteInAdviseId equal...

LINQ to SQL auto-generated type for stored procedure

Hello. I have the following stored procedure ALTER PROCEDURE [dbo].Test AS BEGIN CREATE TABLE ##table ( ID1 int, ID2 int ) DECLARE @query varchar(MAX); INSERT INTO ##table VALUES(1, 1); SELECT * FROM ##table; END And I try to use it from C# code. I use LINQ to SQL as an O/RM. When I add the p...

Linq-to-SQL produces bad SQL?

I am trying to run a Linq-to-SQL query, but when the query is evaluated, I get the following exception: System.Data.OleDb.OleDbException was unhandled Message=The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. Source=Microsoft JET Database Engine ErrorC...

LINQ to SQL - Why can't you use a WHERE after an ORDER BY?

The following code: // select all orders var orders = from o in FoodOrders where o.STATUS = 1 order by o.ORDER_DATE descending select o; // if customer id is specified, only select orders from specific customer if (customerID!=null) { orders = orders.Where(o => customerID.Equals(o.CUSTOMER_ID)...

LINQ to SQL Wildcards

How can I build in wildcards to my LINQ To SQL lambda expression? This is what I have currently: var query = from log in context.Logs select log; foreach (string filter in CustomReport.ExtColsToFilter) { string tempFilter = filter; query = query.Where(Log => Log.FormattedMessage.Contains(tempFilter)); } This works fine up unt...

My Linq to Sql Insert code seems to work fine but I don't get a record in the database

Here is my code. In the debugger, I can see that the code is running. No errors are thrown. But, when I go back to the table, no row has been inserted. What am I missing?? protected void submitButton_Click(object sender, EventArgs e) { CfdDataClassesDataContext db = new CfdDataClassesDataContext(); string sOfficeSought = office...

Strange LINQ to SQL Behavior

Here is my dataset: 1 David 2 David 3 Marc 4 Marc 5 Marc 6 Marc 7 Marc 8 Marc 9 Marc 10 Marc 11 Marc 12 Marc 13 Marc 14 Marc 15 Marc This query returns 2 records (correct): query = query.Where(Log => SqlMethods.Like (Log.FormattedMessage, "%<key>Name</key><value>David</value>%")); This query returns 2 records (correct): qu...

Fast insert relational(normalized) data tables into SQL Server 2008

Hello All, I'm trying to find a better and faster way to insert pretty massive amount of data(~50K rows) than the Linq that I'm using now. The data I'm trying to write to a local db is in a list of ORM mapped data serialized and received from WCF. I'm keen on using SqlBulkCopy, but the problem is that the tables are normalized and are a...

SQLMetal DataContext Associations Not Generated

I am generating the LINQ-to-SQL DataContext and entity classes for a database. The database has several tables, two of which are - [AccountMaster] and [AccountCodes]. There is a foreign key relationship defined between them, with [AccountMaster].AccountNumber being referenced from [AccountCodes]. Adding a LINQ-to-SQL file in VS2008 and ...

Linq to SQL Problem System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager

I have a really tricky thing going up here. My project has around 100 tables and they are all mapped by LINQ. Everything works fine in a dev and test environment. These enviroments are MS Win 2008 r2 servers with SQL 2008 sp1 databases. IIS and SQL are on a different machines. Now on production enviroment which is MS Win 2003 x64 web far...

How to write an "OR" within a Linq to Sql .Where()

I want to get all records WHERE (s.override == 1 OR (s.override == 2 AND s.approved == 1)) How can I do that using the .Where x.subcontracts.Where(s ==> ??) ...

LINQ Foreign Key Relationship Naming (Address, Address1, Address2)

Hello, is it possible to change the foreign key relationship object naming of LINQ to SQL generated objects? For example, I have a Demo table which has the fields ItemMinId, ItemMaxId, ItemExlId which are all foreign key references to my Item table. LINQ generates now Demo.Item, Demo.Item2, Demo.Item3 fields which makes it difficult in...

Why does this render as a list of "System.Web.Mvc.SelectListItem"s?

I'm trying to populate a DropDownList with values pulled from a property, and my end result right now is a list of nothing but "System.Web.Mvc.SelectListItem"s. I'm sure there's some minor step I'm omitting here, but for the life of me I can't figure out what it is. The property GET generating the list: public IEnumerable<SelectListIt...

Linq to Sql Projection Help

I've reached the end of my Linq rope. Need your help! Heres my table structure first(all linq to sql objects): InventoryItems -ID -AmtInStock IventoryKits -ID InventoryKits_to_InventoryItems -InventoryItemID -InventoryKitID So i need to do a projection like the following var q2=from k in GetAllKits()//returns IQueryable...

Add LINQ Auto-Generated Value Marker [Column(IsDbGenerated=true)] in Buddy Class

Hello, is it possible to decorate a field of a LINQ generated class with [Column(IsDbGenerated=true)] using a buddy class (which is linked to the LINQ class via [MetadataType(typeof(BuddyMetadata))]) ? My goal is to be able to clear and repopulate the LINQ ORM designer without having to set the "Auto Generate Value" property manually ev...

Can I have Entity Framework and Linq-to-SQL run together?

I'd like to know if it's possible to have both Linq-to-SQL and Entity Framework running side-by-side. Our current configuration is Linq-to-SQL and we'd like to eventually move to EF. But there's just too much going on in the Linq-to-SQL side right now and we'd like to do it in phases. so any chance we can just start writing new stuff i...

form data posted using linq-to-sql not showing until I refresh the page

I have an asp.net mvc app with a form. When you submit the form, it adds records to the sql database with linq-to-sql. After adding the records, the controller displays the form again, and should show those new values on the form. But, when it displays the form, the values are blank, until you refresh the page. While tracing through ...

MSDTC attempts to enlist client machine in a distributed transaction

Hi there We're seeing the following intermittent warning logged by MSDTC: A caller has attempted to propagate a transaction to a remote system, but MSDTC network DTC access is currently disabled on machine 'X'. Please review the MS DTC configuration settings. However, MSDTC is disabled on machine X by design - it's a clien...