I'm sure that I'm missing something simple here, but in Visual Studio 2008 on my current project only List.Contains(T) is present. Being able to use List.Contains(T, IEqualityComparer(T)) would save me a lot of grief. Any quick thoughts on this? Thanks.
*edit:
using System.Linq is not available to me. Is is possible that my project is ...
I'm trying to build a search page using LINQ to Entities, but the following code is giving me a runtime error about l.t.e. not recognising 'Boolean StartsWith(). The code compiles just fine. How can I work around this better than shipping the StartsWith filtering out to a stored proc?
return from dp in dents.DirectoryPersonEntrySe...
I want to add new admin into my database. But it doesn't work it. Please look at the button1_Click event handler, I need to add value in this event.
public partial class Form1 : Form
{
protected NetTanitimTestEntities adminNameContext;
public Form1()
{
InitializeComponent();
adminName...
How do I call a stored procedure without error in ADO.NET Entity Framework? If I use the code below, I get an error:
adminNameContext.AddItemCategory(12, "ggf", DateTime.Now);
Error:
The data reader is incompatible with the specified 'NetTanitimTestModel.Categories'. A member of the type, 'ID', does not have a corresponding column i...
I am having some problems with a few queries using Linq to NHibernate. These queries are fairly simple for me to do in SQL but for some reason I am having problems with Linq
For example if I want to find all entities which have any of a list of tags attached like this (I have greatly simplified the code for this message):
public class ...
I have a collection of objects of one type that I'd like to convert to a different type. This can be done easily with foreach, but I'd like to figure out how to use Linq's aggregate function to do it.
The problem is all the Aggregate examples use types line string or int, which support the '+' operator. I'd like to have the accumulato...
Hi,
Is is it possible to use l2s in model first approach?
Here's the think i want to achieve:
I want to write my app in TDD manner, so I want to write some domain specific objects first and then base on that generate database model.
One solution is to l2s as DAL but and map linq generated entities to my custom domain objects(I Rob C. in...
Hi All,
I have a model where a Product can have multiple PriceDrops. I'm trying to generate a list of products with the most recent price drops.
Getting the most recent price drops with the products loaded is easy enough, and I thought it would be the best way to start:
dlo.LoadWith<PriceDrop>(pd => pd.Product);
db.LoadOptions = dlo;...
I have 2 tables in my database that I'm trying to create Linq2Sql entities for. There's more to them than this, but this is essentially what they come down to:
Rooms UserActivity
-------- --------
RoomID ActivityID
RoomID (foreign key on Rooms.RoomID)
The UserActivity table is essentially just a...
Like SQL, Linq is a great way to retrieve data from various sources, but to date I haven't heard anyone talking about the other elements that SQL provides, specifically update/insert/delete. The various DLinq providers all offer their own mechanisms, but it seems like at some point modification of a data source would become part of the l...
In MSSQL you can convert a string into an integer like this:
CONVERT(INT, table.column)
Is there any C# expression that Linq to SQL would translate to this?
In C# you can normally do the same by using int.Parse(), but unfortunately, trying to use int.Parse() in a Linq query results in an error:
Method 'Int32 Parse(System.String)'...
class String contains very useful method - String.Join(string, string[]).
It creates a string from an array, separating each element of array with a symbol given. But general - it doesn't add a separator after the last element! I uses it for ASP.NET coding for separating with "<br />" or Environment.NewLine.
So I want to add an empty r...
I am using the following
var validLogin = from P in this.DataContext.Persons
where P.UserName.Equals(login) && P.Password.Equals(password)
select new
{
P.FirstName,
P.LastName,
P.EmailAddress
};
In this now i want to know, is t...
I've got a list of elements of a certain class. This class contains a field.
class Foo {public int i;}
List<Foo> list;
I'd like to extract the field from all items in the list into a new list.
List<int> result = list.ExtractField (e => e.i); // imaginary
There are surely multiple ways to do that, but I did not find a nice-looking s...
Hi i have the following stored proc in SQL Server 2005:
ALTER PROCEDURE [dbo].[slot_sp_EngineerTimeslots_Group]
@PROPREF VARCHAR(50),
@PRIORITYCODE VARCHAR(3),
@JOBLENGTH INT = 0,
@TIMESLOT VARCHAR(3)
AS
SET NOCOUNT ON
DECLARE @TOTALDAYS INT
DECLARE @TOTALDAYSTARGET INT
DECLARE @COUNTER INT
...
I am using listview to display a list of items and a nested listview to show list of features to each item. Both parent and child listview need to able Insert,Edit and delete operation. It works fine for parent listview. But when I try to edit an child item, The edit button does not take it into Edit mode. Can you please suggest me what ...
LINQ default methods for insert/delete/update are coming disabled in visual studio 2008. The methods are grayed out (Use Runtime) and can't change to custom Stored procedures.
I am using ASP.NET MVC web application and LINQ to SQL. Any help will be apreciated. Many Thanks.
...
For the following code
var validate = from P in this.DataContext.Persons
where P.UserName.Equals(login) && P.Password.Equals(password)
select new
{
P.FirstName,
P.LastName,
P....
Can I get return values returned by stored procedure using InsertOnSubmit in LINQ.
The stored procedure return a error number. How can I get this error number InsertOnSubmit (using stored procedure instead of Runtime sql). Many Thanks
...
I have an observable collection and I sort it using linq. Everything is great, but the problem I have is how do I sort the actual observable collection? Instead I just end up with some IEnumerable thing and I end up clearing the collection and adding the stuff back in. This can't be good for performance. Does anyone know of a better ...