I have a foreign key constraint between tables Sessions and Users. Specifically, Sessions.UID = Users.ID. Sometimes, I want Sessions.UID to be null. Can this be allowed? Any time I try to do this, I get an FK Constraint Violation.
Specifically, I'm inserting a row into Sessions via LINQ. I set the Session.User = null; and I get this err...
Hi,
I'm trying to get a web app working based on the S#arp Architecture. At the moment I have a the below code for my entity.
[Serializable]
public abstract class EventBase : Entity
{
#region Properties
[DomainSignature]
public virtual string Name { get; set; }
public virtual string Description { get; set; }
publ...
Hi,
I have some code like this:
Function GetTypeFromTableName(ByVal _TableName As String, ByVal _DataContext As DataContext)
Dim Mytype As Type = (From t In _DataContext.Mapping.GetTables Where t.TableName = "dbo." + _TableName Select t.RowType.Type).SingleOrDefault
Return Mytype
End Function
Dim DBA As New LINQDataContext
_...
Using LinqToSql, I need to return a single (L) for the most recent modDate in a join table (CL).
Tables:
L (Lid, meta1, meta2, ...)
CL (Cid, Lid, ModDate)
Here is sql that produces the expected result
SELECT l.*
FROM L l
INNER JOIN (
SELECT TOP 1 cl.Lid, MAX(cl.ModDate) as ModDate
FROM CL cl
INNER JOIN L l ON cl.Lid = l.Lid AND l.m...
Hi,
I have asked this question on more than one forums and it seems no one would even want to take a crak at it.
My problem is simple and i would guess everyone has run into it when using LINQ to SQL.
If your have a LINQ object called: Person and you would like to poulate a list box based on all of the people you have in your DB the ta...
I've got a simple WPFToolkit DataGrid:
<Grid>
<dg:DataGrid Name="theDataGrid"/>
</Grid>
And in code behind a simple Contact class:
public class Contact
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Contact(string firstName, string lastName)
{
this.FirstName = firstNam...
I'm working on an asp.net-mvc application. The linq data context is being passed into my service objects by structure map. I've got is set to have a scope of hybrid. This all works just fine.
protected override void configure()
{
ForRequestedType<AetherDataContext>()
.TheDefaultIs(() => new AetherDataContext())
.CacheBy(Instan...
In my code I'd like to make my repositories IQueryable. This way, the criteria for selection will be a linq expression tree.
Now if I want to mock my repository in theorie this is very easy : just implement the interface of my repository (which is also a IQueryable object).
My mock repository implementation would be only a in memory co...
I have a web application project within VS 2008 and I have created a linq to sql file onto which I have dragged a table from my data base. The data context is created fine but when I instantiate an object of this type the only item I get showing on the intellisense for it is the class based on the table I dragged onto the designer and ev...
I'm working through the "Data Binding" chapter in Pro WPF in C# 2008.
They have you set up this class:
public class StoreDB
{
public Contact GetContact(int id) {...}
public List<Contact> GetContacts() {...}
}
The idea is to call these methods, getting either a Contact or a List<Contact> and bind these to the appropriate contr...
I'm currently working on a Silverlight app and need to convert XML data into appropriate objects to data bind to. The basic class definition for this discussion is:
public class TabularEntry
{
public string Tag { get; set; }
public string Description { get; set; }
public string Code { get; set; }
public string U...
I need to union two sets of XElements into a single, unique set of elements. Using the .Union() extension method, I just get a "union all" instead of a union. Am I missing something?
var elements = xDocument.Descendants(w + "sdt")
.Union(otherDocument.Descendants(w + "sdt")
.Select(sdt =>
...
Since there is no Linq to DB2 yet (c'mon IBM!), and I want to deal with IQueryables or IEnumerables in my code, how would I convert a DataTable to an IQueryable? Or an IEnumerable?
I have an interface and a class that matches the columns in the datatable...
IQueryable<IMyData> GetAS400Data(..parameters..)
{
DataSet d = GetData();
...
I have an app that loads some XML docs into memory then runs various queries against it using Linq.
The app runs fine on the live server (Windows Server 2003) and under Visual Studio 2008 on XP. But on my Vista laptop (4gb RAM, 2GHz CPU) all the Linq queries run really really slow. What should take a couple of milliseconds instead takes...
I want to write a business object layer in a way that makes each entity object responsible for saving its own changes.
I thought it would be a good way to have each entity posses its own ObjectContext, attach itself to that ObjectContext and perform the transaction whenever it needs to be saved.
In LINQ to SQL, DataContext is very ligh...
To get my head round some fundamentals using MVC and Linq to SQL I'm working on an adaption to Stephen Walther's TaskList application:
I'm adding a Bulk Edit system using the concepts described in Steve Sanderson's blog.
This all works as expected, however, I'm having trouble saving my returned List of Tasks. The Post to my BulkEdit lo...
I'm using Linq CTP May 2006 for VS2005 (I have to use it, so please, don't suggest VS2008).
The problem is that it doesn't create objects in proper way. I see several solutions:
1) Use DLinq (Disadvantage: doesn't support Language integrated queries)
2) Use SqlMetal (Disadvantage: the same)
But none of them suites me. So the question i...
Hello. I am developing Web Custom control which able to apply filters to the LinqDataSource object. It is generic control since it should operate with object of certain type.
The control knows what field of object it should operate by following field
/// <summary>
/// Method to get compared column from object
/// </summary>...
Ok, so this is an alternative to this question.
I'm trying to produce an MVC application using LinqToSql that allows for bulk editing of data on a single page.
Imagine a simple table Item with ItemId, ItemName, ItemPrice as fields.
There are many examples out there of extrmely simple MVC applications that show you a list of these item...
Is there a direct LINQ syntax for finding the members of set A that are absent from set B? In SQL I would write this
SELECT A.* FROM A LEFT JOIN B ON A.ID = B.ID WHERE B.ID IS NULL
...