Hi !
i have a situation when i cant just update original record in database, but instead make a new record, copy all fields from old and apply changes to new one.
(something like this if translated to code)
var original = from _orig in context.Test where _orig.id == 5 select _orig;
Test newTest = new Test();
newTest = original;
newTest...
Per the many examples of LINQ I've seen, I'm creating my own data context and tables using code similar to the one below:
class MyDatabase : DataContext {
public Table<Widget> Widgets;
public Table<Car> Cars;
public MyDatabase (string connection) : base(connection) { }
}
But for every table (Widgets, Cars, etc), I get the warn...
I have 3 tables:
Companies,
Subcontracts, and
CompanyToSubcontract
The CompanyToSubcontract table is the guid of the Company and guid of the Subcontract. I have a MultiSelectList on the Subcontract Edit and Create views where the user can select multiple companies. I finally got it working where it displays the correct companies as se...
This is an in-depth continuation of my question from earlier this morning, which I'm still stumped about. I'm using a strongly typed DataContext for my application and although it emits a warning, it magically works. How does it do this?
Here's the code one would typically use to connect to a database using LINQ-to-SQL.
class MyDatabas...
Trying to retrieve data using linq from a database. I would like to use anonymous types and convert to an Ilist, Array, ArrayList or Collection. The data is used in a third party object that accepts Ilist, arraylist or collections.
I can't seem to get this to work. I get the following error, "Sequence operators not supported for type ...
I wasted the better part of the day on this and am no closer to a understanding the issue than what I was this morning.
I am looping through a set of objects and marking them for deletion. The 2nd one always causes the above exception. tb_invoice has a FK to tb_shipment.
As always, I am probably missing something very obvious, but I ha...
Has anyone here have used LINQ to SQL to support the persistence of domain
models?
I'm not planning to use the LINQ2SQL entity designer, just plain-old hand-coded XML mapping and I'm currently having roadblocks.
I'm attempting to use it in a DDD example I'm doing, since my audience only knows LINQ2SQL.
...
I am developing a new web application which would be simple and i decided to use asp.net mvc and Linq to sql..
I thus far have no idea about Linq to Sql...
How to get started with Linq to sql?
What should i watch out for when using Linq to sql?
...
I'm trying to implement a validation framework in a base class for LINQ to SQL entities. The problem I'm having is getting the OnValidate event to fire properly.
The reason is that OnValidate is marked as partial so I can't provide a default implementation in the base class; it gets hidden by a new method declared by the LINQ to SQL cl...
I have a requirement to find rows in a table containing 200,000 entries. Some may not consider this 'large', but it is large enough to warrant performance considerations.
The table contains strings consisting of digits only. For instance, the user can enter something like '12340-0560-78', or portions of this, e.g. '0560', and I need to ...
I've got a deadline for an initial release of a client-server application that will have lots of iterative releases subsequently.
NHibernate is the ORM of choice, largely by reputation and my desire to gain experience with it.
The problem is that I haven't even had a chance to spike NHibernate yet, and I'm afraid that doing so is going...
I have a class that needs a property set inside a LINQ-to-SQL query. My first attempt was to have a "setter" method that would return the object instance and could be used in my select, like this:
public partial class Foo
{
public DateTime RetrievalTime { get; set; }
public Foo SetRetrievalTimeAndReturnSelf ( DateTime value )
...
I have the following LINQ query. The problem is it's returning 13k results when tblSurveys only has 20 total. What am I doing wrong?
from s in surveyContext.tblSurveys
from st in surveyContext.tblTypes_for_Surveys
from t in surveyContext.tblSurvey_Types
where (s.Survey_Date >= startDate && s.Survey_Date <= stopDate) &&
(s.Unsubst...
I think that perhaps the original question was too long-winded with too many unnecessary details, so this is my attempt to simplify.
I am looking for a means to perform any of the actions below. I only need to do one, not all. If anyone knows the answer to even one of these, please respond. So, is it possible to do any of the followi...
I have made an entry field required somehow but I'm not sure how. When editing a tag, the tag owner entry field should be able to be empty.
I have set "allow nulls" in the database table:
Does anyone know how I can fix it? To be clear, I want the above form to be submitted without requiring a value for tag_owner.
...
I expose an IQueryable method from my business layer for use in other layers. I would like to execute a function against each of the items in the enumeration, once the query has executed down-level.
It seems like there should be an event that is raised after the query executes, so that I can then operate on the results from this common...
I need to filter a list of both parent and child rows and return the parent object with the filtered child objects. This is from a shared library so cannot be an anonymous type (var)
I have a Parent object with Children (well, child objects). I want to return the parent object with parentId = 1 with a filtered set of child objects (it...
I have 3 tables Subcontract, Company, and a link table CompanyToSubcontract. The link table contains the Subcontract_id and the Company_id. The foreign keys were set-up in SQL and when I drug them into my dbml the one-to-many relationship arrows showed up and everything looked fine. However, when coding, it's as if the relationship is...
I'm using visual studio 2008 and I've created a stored procedure that selects back two different result sets. I drag the stored proc on to a linq to sql dbml datacontext class, causing visual studio to create the following code in the cs file:
[Function(Name="dbo.List_MultiSelect")]
public ISingleResult<DataAccessLayer.DataEntities.Lis...
I'm writing a database test against a repository that uses L2S. In my database I have a Manifest entity and an AllocatedTransaction entity. The AllocatedTransaction entity has a foreign key to the Manifest's id. The DDL looks something like this:
Manifest:
Id - int - identity
AllocateTransaction:
Id - int - identity
Quantity - int
M...