NorthwindDataContext - where to get this class from?
Hi, In a lot of the tutorials online for learning LINQ, they use a NorthwindDataContext. From where is this retrieved/generated? Thanks ...
Hi, In a lot of the tutorials online for learning LINQ, they use a NorthwindDataContext. From where is this retrieved/generated? Thanks ...
It's well known that you cannot set foreign key IDs directly in Linq to SQL if the entities have already been loaded. You can however look up the entity by it's foreign key and then set the entity as the foreign entity using the entity relationship. (I've taken out the enum here and used integer values for simplicity). i.e. If I have a...
Is there any way to set a property that is not generated by Linq to SQL designer (is not a column in database) in a query? For example is there such a method like SomeMethod(): IQuaryable<T> query = (from t in context.MyTable where {some conditions} select t).SomeMethod("MyPropertyName", valu...
Are Select and SelectMany preferrable to Joins? The reason I'm wondering is because I use LinqPad and in one section there are comments that say: // Note: before delving into this section, make sure you've read the preceding two // sections: Select and SelectMany. The Join operators are actually unnecessary // in LINQ to SQL, and the e...
I have a Stored Proc that do a validation on a parameter ex. IF @SearchType = 'BNa' BEGIN ... DO something END ELSE IF @SearchType = 'SNa' BEGIN ... DO something END So by default the Stored Proc return a scalar value and if SearchType = something valid it will return a IMultipleValues. The problem is that when I drop my Sto...
Does something like this affect performance badly? var myQuery = from c in Customers select c; var filter1 = from c in myQuery where c.ID > 2 select c; myQuery = filter1; var filter2 = from c in myQuery where c.Name.Contains("r") select c; myQuery = filter2; When I do this it seems to only do the actual query at the end, not on ev...
For example, in my WCF, if I have a Customer table and an Order table that have an association to each other on Customer ID. I want to get the Count of the number of Orders for each Customer. In regular VB code I can just do this: Dim CustID As Integer = 1234 Dim cust As New MyService.Customer() cust = cust.GetCustomer(CustID) Respons...
I'm looking to learn more about Linq to Sql, but I'm looking for a quick getting started tutorial. Can anyone recommend one? ...
I'm working on a personal project (C# / ASP.NET) that will use LINQ to SQL. The Solution will have (so far) a Webform project, a Namespace project (business logic), and a Tests project. I'm in the very early stages so far (clearly in Design phase). Is there a paradigm for 3-Tier Architecture here? It seems like the DAL is entirely usele...
I built a template-based document generator using the Open XML SDK (1.0), the Word 2007 Content Control Toolkit and LINQ to SQL (using the CodeSmith PLINQO templates). To do this, I serialized the LINQ to SQL entities to XML by retrieving the entity using DataLoadOptions specified in the source code. This works great, except that to ini...
I've been trying to develop a linq query that returns the ItemNumber column of all my tables in the database, but so far I haven't been able to do it successfully. Basically I have a table for each kind of hardware component in a computer, and each table has a ItemNumber column. I need to query all of the tables in one bang, and return ...
Despite this being one of the best error messages I've ever seen (second only to, "This operation could destabilize the rent in the space-time continuum"), it's also one of the most frustrating. I have developed an ASP.NET MVC site which works perfectly through VS2008. It works perfectly hosted on a local IIS7 server (Win2008Server & W...
Assume we have a method like this: public IEnumerable<T> FirstMethod() { var entities = from t in context.Products where {some conditions} select t; foreach( var entity in entities ) { entity.SomeProperty = {SomeValue}; yield return entity; } } where context is ...
After too much thought, I've decided to use Linq To SQL as a DAL for my project, but keep the business objects as POCO objects. This will give some flexibility because the database schema is old and have some problems that can not be solved, because backward compatibility. I'm thinking about making some methods to retrieve or complete ...
Hi there im using Linq for check if two user fields correspond for an unique user register in SQL Table, for example UID : userID PIN : passID so fields have to be from a single user, i was trying this: public bool AutentificacionUsuario(string userID , string password passID) { USER _userID = _db.USER.FirstOrDefault(uid ...
I have a Task object that has a collection of Label objects ... in the database the tables are called Task and Label. There are a variety of ways to search for a Task, so using LINQ, I construct my LINQ query in an expression tree ... similar to the below code sample: IQueryable<Data.Task> query = ctx.DataContext.Tasks; if (crit...
I'm trying to customize entities of my application to make them have a property referencing the DataContext that loaded them. I think the best way is to somehow create a class that implements the IQueryable and set the entity datacontext property in its GetEnumerator method. My question is, how can I use the Provider and Expression use...
Why does this work: result = (from e in db.CampaignCodes where e.Code.Equals("") && e.Domain.Equals(null) select e).FirstOrDefault(); But not (result is null): String code = ""; String domain = null; result = (from e in db.CampaignCodes where e.Code.Equals(code) && e.Domain.Equals(domain) select e).FirstOrDefault(); ?? ...
I'm using ONLY Linq to SQL for database access, so I assume it is safe to turn off request validation... ...
I have a DataGridView control in a winforms app that I'm working on. The DataSource is set to IQueryable that I get from our service layer: dataGridView1.DataSource = (from c in _customerService.GetAll() select c); In the example I'm working on, I have a cancel button that I wish to use to revert changes. If they hit cancel, I do not...