What I have:
LINQ to SQL auto generated class, which corresponds to the shape of its SQL table.
TABLEA
========
column1
column2
What I want to do:
Extend TABLEA class to include a new property, whose related column will be present only when a particular stored procedure is called. The stored procedure return type will be of TABLEA....
I'm helping implement a SQL Server 2008 database and I have several columns that I'd like to default to the next number in a sequence, but still be able to insert numbers by hand into it at will. In PostgreSQL this is done with the SERIAL datatype and a sequence. Unfortunately those things do not exist in SQL Server. Here's what I know W...
I have a Dictionary which I'd like to use like an IN clause within a SQL query.
I have a Linq-To-SQL query where I would like to use this Dictionary's Keys to check fields in the rows for the query.
E.g.
bool result = DataContext.Table.Any(res => MyDictionary.ContainsKey(res.field1));
In effect this is similar to
exists(sel...
Lets say I have a couple Linq to SQL classes, Person and Department. Person has a entity association to Department.
I can catch a change to Person.Name using OnNameChanging and OnNameChanged in the partial class but the designer generated code doesn't seem to call OnDepartmentChanging or OnDepartmentChanged. How can I catch these kind...
I've got a Linq 2 SQL object I'm trying to update. Two of the properties on this object are related to each other, and setting one sets the other.
So if I do:
Foo.Code = BEER;
The Foo.CodeID property will automatically be set to 5 (or whatever.)
The problem is that LinqDataSource sets Foo.Code, then immediately sets Foo.CodeID... wh...
The basic problem...
I have a method which executes the following code:
IList<Gig> gigs = GetGigs().WithArtist(artistId).ToList();
The GetGigs() method gets Gigs from my database via LinqToSql...
So, when GetGigs().WithArtist(artistId).ToList() is executed I get the following exception:
Member access 'ListenTo.Shared.DO.Artist Arti...
I it was possible to do this in Active Record, but is this feasible with Linq to SQL?
...
Say I have a role entity and a site entity. Now there are many roles to one site, so on the Role class there is a Site property that represents that relationship. If I wanted the roles for a site I would do this:
Site.Roles.Load()
Problems is, since the Site property on the Role class isn't a collection but just a single entity, the...
If you're going to be moving from LINQ to SQL to the Entity Framework what features do you most want to see move along with it? What features do you think are requirements to move existing projects?
...
Allow me to start with: I am a n00b on ASP.NET MVC. I love it, but I am a n00b.
I am trying to pass "complex" data back from a LINQ query. I understand how to use the data context and then just cast that data when I send it back, but when I do a more complicated LINQ query which returns an anonymous type, things break down.
I saw som...
I've a procedure where I need to save a entity object. The problem is that I don't know if this entity is attached to my datacontext or not. To solve this I use the following code:
try
{
db.ClientUsers.Attach(clientUser);
db.Refresh(RefreshMode.KeepCurrentValues, clientUser);
}
finally { }
db.SubmitC...
How can I use Linq to SQL to retrieve @@DBTS using C#?
Here is what I am trying:
IEnumerable<System.Data.Linq.Binary> results = db.ExecuteQuery<System.Data.Linq.Binary>(@"SELECT @@DBTS");
However, this results in "The type 'System.Data.Linq.Binary' must declare a default (parameterless) constructor in order to be constructed during ma...
I have a form in which I am able to list a parent table using datagridview. I also have a child payment table that list all the payments made. I have added a combo box so I can make my search more efficient. Everythhing worked great until I added to box. Now I get this error==
InValidCastException == Conversion from string "" to type 'D...
The SQL server doing queries based COLLATE option, so you can define how comparision will be performed (case sensitive or not). You can do it when you creating table or during query execution.
How can I control collation during my LINQ to SQL queries? Will my queries be allways case insensitive when I will do table.Column == stringValue...
As I've stated before I'm working on a digg clone to teach myself ASP.NET MVC Inside and out but I've hit a road bump that I can't seem to avoid.
I want to be able to optimize this application as much as possible so I have my DAL which is a bunch of classes of ...Repository : Repository. Now to help optimize for performance I have my b...
I am trying to do what I think is something simple, but I suspect I am simply too n00b to know that I am probably doing something wrong. I have a LINQ query return:
IQueryable<CWords> Result
Where CWords is a class I defined as follows:
public class CWords
{
public CWords(){}
public string _column1{ get; set; }
public fl...
I'm trying to figure out how to do this, and I"m stumped. I'm sure it's something simple that I'm just missing.
Say I have a table that is a collection of names, and I want to check if a subset of those names exist like this:
var names = new List{ "John", "Steven", "Mary"};
var dbNames = from n in Db.Names
where n.FirstNa...
Hi,
Well i feel im missing something here because im having problems i bet a bunch of people ran into before and i cant find any solutions to this simple scenario.
Application Technology:
WPF, 3.5(sp1) framework, LINQ to SQL, o/r designer CRUD, Visual studio 2008, C#.
Apllication Layout:
Main layout conatins a panel to the left holdi...
Is there a way to ensure a particular conditional clause is added to the expression tree on each select from a particular table?
For example, a table with a field with the date a record was deleted should never come back or be included in any kind of statement.
Rather than include a where clause each time, is there a way, without cre...
Given the following piece of code:
using(var data = new SomeDataContext(ConnectionString))
{
data.ObjectTrackingEnabled = false;
foreach(Something in data.Somethings)
someList.Add(something.SomeProperty);
}
Is it worth it setting object tracking to false? I know it is just one line of code, but it kind of bugs me having to w...