linq-to-sql

enumerate entity children

I need to create a method that will take Linq-to-sql entity and return a list of all it's children(only 1st generation) entitysets, without any data that entitysets contain, just names. Is there any way I can do that? Thanks ...

MVC 2 EditorForModel() rendering foreign key table names

I have an interesting problem and wanted so see if anyone else has seen this. I've created a MVC 2 site using Visual studio 2010 beta 2. I'm using linq to sql data model objects with data annotations. In my data model objects I'm using [ScaffoldColumn(false)] attribute to exclude the foreign key ID's from rendering to the UI when I use...

Trying to Join columns with LINQ

So far after watching the tutorial videos on link, im fine accessing one data table and dealing with the results. On putting this into practice at the office I am faced with a lot of joins that I need to convert to LINQ... SELECT Modules.TemplateFileName FROM Modules INNER JOIN Grouping ON Modules.ID = ...

Linq to sql VS Entity Framework VD NHibernate performance in an ASP.NET 3.5 Mashup style Application

I am tasked to build a web 2.0 style mashup application which consumes a lot of 3rd party webservices like youtube and twitter. There are also lots custom features which are going to be built using ASP.NET 3.5 and SQL Server 2008. Now I am looking for the right ORM for my needs. From a performance and ease of use standpoint can anyone su...

How to do a full outer join in Linq?

I've inherited a database that wasn't designed exactly optimally, and I need to manipulate some data. Let me give a more common analogy of the kind of thing I have to do: Let's say we have a Student table, a StudentClass table keeping record of all the classes he attended, and a StudentTeacher table that stores all the teachers who tau...

Money vs Decimal datatypes when using LINQ to SQL

There are lots of discussion about using MONEY or DECIMAL datatypes in SQL Server for holding financial data. It seems all it is about possible lost of precision when using MONEY datatype. If I understand it right, this situation may take place when we do calculation with these values in stored procedures using T-SQL. Do I assume righ...

Updating an Entity with LINQ TO SQL

I´m trying to update a db record using linq to sql First i query for it MyObject obj = (from o in objRepository.List where(o.ID == id) select i).SingleOrDefault(); then I try to update and modify the data obj.Name = "some value" dataContext.Attach(obj) dataContext.Context.Refresh(RefreshMode.KeepCurrentValues, obj); I'm getting a...

Best way to implement a read and write for an unknown amount of rows

I asked a question similarly, but the outcome was pretty messy and I was having difficulties populating so I'm trying to go at from a different angle: http://stackoverflow.com/questions/2060835/question-concerning-asplistview-and-multiple-dynamically-created-controls I have a table which stores steps in a process. Some companies only h...

Multiselect list not showing selected items in c# mvc using linq2sql

I've tried many different ways to pass the selected items to the multiselect list with no luck. Finally, I tried this, which I think should display all the items as selected and still nothing in the list is selected. public MultiSelectList Companies { get; private set; } Companies = MulitSelectList(subcontractRepository.SubcontractCom...

Linq To SQL problem - has no supported translation to SQL (problem with C# property)

I'm extending some Linq to SQL classes. I've got 2 similar statements, the 1st one works, the 2nd does not ("has no supported translation to SQL" error). var reg2 = rs.ProductRegistrations().SingleOrDefault(p => p.Product.product_name == "ACE") var reg5 = rs.ProductRegistrations().SingleOrDefault(p => p.product_name == "ACE"); After...

Error deleting a record using Linq2SQL

I've received an error report from a client recently and am having no luck resolving it. I'm hoping someone can give me some insight to what may be wrong. The error seems simple enough: Csla.DataPortalException: DataPortal.Delete failed (System.InvalidOperationException: Sequence contains more than one element at System.Linq.Enumerab...

Aggregate in where clause of LINQ

I am trying to write a LINQ statement which selects only the rows in a table with the most recent rundate. For example, if I had a table with columns RunDate(datetime) and Value(decimal) one way of accomplishing this through sql might look like: SELECT Value FROM Table WHERE RunDate = (SELECT MAX(RunDate) FROM Table) Is there a way t...

LINQ to SQL performing OR on strings

Hello, I'm just looking to perform a LINQ query to return a group of course ID's and Course Titles which are running next year. As part of this I need to perform an OR query as I'm also looking to return data relating to next year as well which is held as a string in my databse and is the only issue I'm having, so any help would be appr...

LINQ to SQL vs ADO.NET - which is faster?

Since LINQ to SQL basically is a layer on top of ADO.NET it requires some translation. Does this mean that using ADO.NET directly is faster than LINQ? Or is the difference so small that it is irrelevant? ...

End user add values to a dropdownlist?

I'm populating a dropdownlist in c# asp.net-MVC from a SQL table using Linq2Sql. I'd like for the user to be able to enter something that isn't in the list into the drop down and have it add to the table. Is this possible? ...

Silverlight 3 treeview load problem with RIA LinqToSql

I have Silverlight 3 project with a treeview which i populate from a table with hierarchical data using linqtosql via RIA domain services. The problem I face is that the treeview displays both data from the top level and sub-levels side by side. I have seen various examples of how to control this, but have not been able to do it myself...

How should I go about making sure the value pairs in this table are unique?

I am using Visual Web Developer and Microsoft SQL server. I have a tag table "Entry_Tag" which is as follows: entry_id tag_id I want to make the entry_id and tag_id pairing unique. A particular tag can only be applied to an entry once in the table. I made the two columns a primary key. They are also both foreign keys referencing the id...

Linq where column == (null reference) not the same as column == null

I came across a rather strange problem with linq-to-sql. In the following example, var survey = (from s in dbContext.crmc_Surveys where (s.crmc_Retail_Trade_Id == tradeId) && (s.State_.Equals(state)) select s).First(); If tradeId is null, it doesn't behave as if I h...

linq sql - aggregate count

I have some linq that returns the correct data. var numEmails = (from row in EmailBatchProposal where row.EmailBatchId == emailBatchId select row.EmailBatchProposalId).Count(); However, if I understand linq correctly, this does not perform optimally. It grabs all the data and then walks through the list and counts the rows. What I'...

LINQ join with filter criteria

How is something like this done in linq? It has filter criteria on the JOIN. This is taken from this question: http://stackoverflow.com/questions/1401889/sql-filter-criteria-in-join-criteria-or-where-clause-which-is-more-efficient select salesman.salesmanid, max(sales.quantity) from salesman inner join sales on salesman.salesmanid =sa...