I've been using this piece of code I've written and it's working in this most unclear manner. I wish to insert a row into the database which includes two columns of DateTime:
myrow.ApprovalDate = DateTime.Now
myrow.ProposedDate = DateTime.Now
And yet, when I update the database I receive this error:
SqlDateTime overflow. Must be b...
I have two projects using legacy databases with no associations between the tables. In one, if I create associations in the DBML file, I can reference the associations in LINQ like this:
From c In context.Cities Where c.city_name = "Portland" _
Select c.State.state_name
(assuming I added the link from City.state_abbr to State.state_ab...
How can I get WCF to allow the following?
Dim EmployeeID as Integer = 10
Dim emp As New WcfServiceLibrary1.Employee(EmployeeID)
Response.write (emp.LastName)
Currently I have to do this because I can't figure out a way for WCF to allow for Parameterized Constructors:
Dim EmployeeID as Integer = 10
Dim emp As New WcfServiceLibrary1.Em...
I've got a ListView which binds to a LinqDataSource and displays selected locations. The insert item Contains a dropdownlist that pulls from another LinqDataSource to give all the unselected locations.
The problem is that I get the following error when loading the page:
Databinding methods such as Eval(), XPath(), and Bind() can only ...
I have a Linq to SQL DataContext with SQL functions into it. While the retrieve object is good, I would like to add a property to the object and same time shortens the object name. So I made an object Reminder that inherits from the Linq to SQL object fnRTHU_ReminderByTaskResult with the property I wanted.
public class Reminder : fnRTHU...
Is there a way to perform a top (Take) linq query using percentage? The T-SQL would have been:
SELECT TOP 20 PERCENT ...
But LINQ seems to only want an int.
It seems that I would have to do a count and then a take. Any suggestions?
...
I have a table 'lasttraces' with the following fields:
Id, AccountId, Version, DownloadNo, Date
The data looks like this:
28092|15240000|1.0.7.1782|2009040004731|2009-01-20 13:10:22.000
28094|61615000|1.0.7.1782|2009040007696|2009-01-20 13:11:38.000
28095|95317000|1.0.7.1782|2009040007695|2009-01-20 13:10:18.000
28101|15240000|1.0.7....
Hi, I'm new to LINQ expressions and trying to get the following to work:
public IQueryable<Models.Powerups.Powerup> GetPowerups(Guid userid)
{
return from p in dc.Powerups
where p.UserId == userid
select (Models.Powerups.Powerup) new DataContractSerializer(Type.GetType(p.Type, true)).ReadObject(new XmlTextReader(new StringRea...
I am attempting to experiment with linq to sql using this site as a guide.
When running a test I keep getting an error parsing the mapping file I created. The error:
System.Xml.Schema.XmlSchemaException : Database node not found. Is the mapping namespace (http://schemas.microsoft.com/linqtosql/mapping/2007) correctly specified?
Her...
Hi
I'm writing an .NET 3.5 web application that is using LinqToSql for the basic database stuff. I'd like to use the nLog library for logging. This library can log to a database using good ol' fashioned stored procedures (not that there is anything wrong with that..) but I'd like to use the LingToSql DataContext to log to the database
...
I decided to use LINQ to SQL in my personal project after hearing lots of goods. Is there any thing I need to taken care before start using it (during initial design)?
...
I'm setting up a public site and the first thing on my mind is SQL injection. I have some text fields I'm saving and am using linq to update/write to the database. Am I safe using linq?
This example is creating the user account.
Data.MemberRegistrationDataContext context = new MemberRegistrationDataContext();
...
I have a generic class
public MyClass<TContext, T> where TContext : DataContext
that effectively acts on an instance of another
public class MyOtherClass<T> : IEnumerable<T>
I want to enforce that the TContext has a Table<T>. Is there a clean way to enforce this?
...
I'm looking to add an "advanced search" capability to my ASP.NET/SQL Server 2005 application. Ideally, I'd like it to be table driven. For example, if my schema changes with the addition of a new column to a table that I want to search, I'd like to have the UI reflect the addition of the new column as a searchable field. I can envisio...
If I have a table with a title column and 3 bit columns (f1, f2, f3) that contain either 1 or NULL, how would I write the LINQ to return the title with the count of each bit column that contains 1? I'm looking for the equivalent of this SQL query:
SELECT title, COUNT(f1), COUNT(f2), COUNT(f3) FROM myTable GROUP BY title
I'm looking fo...
Using LINQ to SQL
db.Products.Where(c => c.ID == 1).Skip(1).Take(1).ToList();
executes
SELECT [t1].[ID], [t1].[CategoryID], [t1].[Name], [t1].[Price], [t1].[Descripti
n], [t1].[IsFeatured], [t1].[IsActive]
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[ID], [t0].[CategoryID], [t0].[Name
, [t0].[Price], [t0].[Description], [t0].[...
How do I do a Case WHEN in Linq to SQL (vb.net please).
In SQL it would be like this:
SELECT
CASE
WHEN condition THEN trueresult
[...n]
[ELSE elseresult]
END
How would I do this in Linq to SQL?
...
I am a somewhat experienced Rails developer and I thought I would try out ASP.NET's version of MVC. In doing so I also decided to try Linq->Sql...
I am a bit confused about the way Linq->Sql handles joins.
A trivial example of my schema is :
books:
id
title
categories:
id
name
books_categories:
book_id
category_id
Simply dragging...
Hello,
I have a basic hierarchy defined in an SQL table:
Id ParentId Name
----------------------
1 Null Root
2 1 Node1
3 2 Node2
Is there a good LINQ-ish way to get the full path of a node? For example, i want to pass the Id of Node2 and get the full path like Root/Node1/Node2.
Thank you in advanc...
I have the problem that when calling SubmitChanges() objects that have not been attached to a collection or added using InsertOnSubmit(), are still being inserted into the database.
I read online that when assigning an object to a property that represents a foreign key, this object is automatically added to the collection of objects to ...