linq-to-sql

Using LINQ to query database through a proxy server of some kind?

Hey All Sorry for using (perhaps) the wrong lingo, but my question may be clearer if you view this diagram as you read it. http://dl.dropbox.com/u/13256/DIAGRAM.PNG Our client is requiring us to adhere to the server configuration (poorly) diagrammed in the above image. The web server is accessible over port 80 and is where our web app...

Future of Linq to Sql and Entity Framework

I work on a project and want to use an ORM. What should I use: Linq to Sql or Entity Framework? Linq to Sql provides more opportunities, as I see, for example support for enumeration types. However, also it is said that, Linq to Sql was for playing and learning for Linq and future strategy of Microsoft lies on Entity Framework. So which ...

Type or namespace could not be found

I'm using LINQ to SQL to connect my database to my home page. I created my datacontext (named businessModel.dbml) In it I have two tables named Category and Business. In home controller I reference the model and attempt to return to the view the table: var dataContext = new businessModelDataContext(); var business = from b in dataConte...

Auto-generated values for columns in database

Is it a good practice to initialize columns that we can know their values in database, for example identity columns of type unique identifier can have a default value (NEWID()), or columns that shows the record create date can have a default value (GETDATE()). Should I go through all my tables and do this whereever I am sure that I won'...

Why can't you return a List from a Compiled Query?

I was speeding up my app by using compiled queries for queries which were getting hit over and over. I tried to implement it like this: Function Select(ByVal fk_id As Integer) As List(SomeEntity) Using db As New DataContext() db.ObjectTrackingEnabled = False Return CompiledSelect(db, fk_id) End Using End Functio...

Cannot add an entity that already exists. (LINQ to SQL)

Hello guys, in my database there are 3 tables CustomerType CusID EventType EventTypeID CustomerEventType CusID EventTypeID Dim db = new CustomerEventDataContext Dim newEvent = new EventType newEvent.EventTypeID = txtEventID.text db.EventType.InsertOnSubmit(newEvent) db.SubmitChanges() 'To select the last ID of event' Dim lastE...

Long Running Stored Proc - Report Progress Using BackgroundWorker & Timer

While a long running stored proc (RMR_Seek) is executing (called via a Linq-To-SQL data context) I am trying to call another stored proc (RMR_GetLatestModelMessage) to check a table for the latest status message. The long running stored proc updates the table in question with status messages as it executes. I want to display the status...

LINQ-to-SQL: Searching against a CSV

I'm using LINQtoSQL and I want to return a list of matching records for a CSV contains a list of IDs to match. The following code is my starting point, having turned a CSV string in a string array, then into a generic list (which I thought LINQ would like) - but it doesn't: Error Error 22 Operator '==' cannot be applied to operands of ...

Can you use the same Enum in multiple entities in Linq-to-SQL?

In my persistence layer, I've declared a load of Enums to represent tables containing reference data (i.e. data never changes). In Linq2SQL, I am able to set the type of an entity property to an enum type and all is well, but as soon as I set a second entity's property to use the same enum type, the Code Generator (MSLinqToSQLGenerator)...

Orderby() not ordering numbers correctly c#

Hi all, I am writing an app for my company and am currently working on the search functionality. When a user searches for an item, I want to display the highest version (which is stored in a database). The problem is, the version is stored as a string instead of int, and when I do an OrderBy(q=>q.Version) on the results, they are retur...

Speeding Up Queries with LINQ

I am transferring about 350 rows (with some data collection) from a MS SQL Server to the iSeries for processing. I feel the process is too slow which is about a minute or so. I am doing all of the MS SQL stuff in LINQ2SQL. Here is the basics of what I am doing currently: Collect all of the vehicle master data to process one-at-a-time. ...

Databinding to a sub object declarative syntax?

What is the format for databinding to a complex "object"? I have a linq to sql class that has containment, i.e object.containedobject. I want to reference the sub objects fields declarative. So I've tried my MySubField.MyBasicProperty and that did not work, as well as, MySubField_MyBasicProperty. Thanks for any help! ...

StructureMap and LINQ to SQL Connection String

Hi, I am currently setting the connection string for my linq to sql data context by using a wrapper class so that I can pass a connection string into the generated DataContext constructor: public class DB : GeneratedDataContext { public DB() : base(ConfigurationManager.ConnectionStrings["myconnectionstring"].ConnectionString) {...

What is the preferred sql server column definition to use for a LINQ to SQL Version property?

We are using the IsVersion property on the ColumnAttribute on a property in a LINQ to SQL class for optimistic concurrency checks. What should the column definition be in the database? Currently we are using version_number int NOT NULL IDENTITY (1, 1) Do we need Identity? Can we get LINQ to SQL to update the version number for us? T...

LINQ query help needed for Intersect

Hi, LINQ gurus, I am looking for help to write a query... I have a table with Person records, and it has a nullable ParentID column, so it is kind of self-referencing, where each record might have a Parent. I am looking for unprocessed rows whose parent rows were processed. This SQL works fine: SELECT * FROM Person where IsProce...

Handling null values in where clause using LINQ-to-SQL

The LINQ-to-SQL query in Visual Studio generates an SQL query with errors. In LINQPad, the same LINQ query using the same database (or DataContext) runs just fine. LINQ Query var accesDomaines = from t in db.Access where t.IdUser == access.IdUtilisateur where t.IdDomain != null whe...

Following NerdDinner tutorial, don't allow duplicate

My sql database doesn't allow 2 records to be added with the same number. If I try to create a record with a previously used number or edit a record to use a previously used number, it doesn't allow it and returns to the edit/create page with an asterisk by the subcontract number field. I would like to add a Rule Violation for this so ...

How to use a system stored procedure in LINQ to SQL

I'd like to add the "msdb.dbo.sp_help_job" system stored procedure to a LINQ to SQL object, but I can't figure out how to specify it. If I create a new Data Connection in Server Explorer and specify the "msdb" database of the server I want, and navigate to "Stored Procedures", that procedure is not listed. Am I looking in the wrong place...

Linq to Sql DB Object to Domain Object mapping and performance

I'm having a problem trying to make my LINQ to SQL queries and the mapping to my domain objects DRY without incurring the cost of multiple round trips to the db. Given this example: var query1 = from x in db.DBProducts select new MyProduct { Id = x.ProductId, Name = x.ProductName, ...

improve security at "database layer" - only select queries allow

I am building a application in silverlight which will enable users read information about their payment. Their login and password will be save in table in db. It is possibility to improve security in my app by limiting what data a query has access to? For instance i want to prevent a user from selecting data they do not own. A limitati...