I have several stored procedures which return a strongly typed result set.
I've learned that Linq has its own method for handling that, which must be overwrote (or at least it seems that way).
My problem is Visual Studio insists on forcibly recreating stored procedures sometimes. I want to disable this.
Here is my manually modified fil...
I've got a linqtosql query filtering and ordering by a datecolumn that takes 20 seconds to run. When I run the generated sqlquery directly on the DB it returns in 0 seconds.
var myObjs = DB.Table
.Where(obj => obj.DateCreated>=DateTime.Today)
.OrderByDescending(obj => obj.DateCreated);
The table has only 100,000 records and the DateT...
If you have a load of tables in your design view, its hard to find a particular one, is there an easy way?
...
If I have this SQL query:
"select distinct top 1 'PostId' = isnull(RootPost,Id), PostedDateTimeUtc from Post order by PostedDateTimeUtc desc"
And I need to enumerate the results with a DataContext. That is to say, how do I send this SQL to a DataContext and parse the result?
How do I do that? What would a method that returns the resul...
How would I convert this query from SQL to Linq:
SELECT status As 'Status',
count(status) As 'Count'
FROM tbl_repair_order
WHERE contract = 'con' and
(status = 'Parts Arr' or
status = 'NA' or
status = 'New Call' or
status = 'Parts Ord' or
status = 'Parts Req' or
status = 'F Work')
G...
I'm getting the following exception when I try to update a table using Linq To Sql:
El valor de miembro 'IdSeccionNovedad'
de un objeto de tipo 'Novedad' ha
cambiado. No se puede modificar un
miembro que define la identidad del
objeto. Agregue un nuevo objeto con
una nueva identidad y elimine el
existente.
wich first se...
Hi, I thought you could do this with linq, but it always throws a foreign key error and the ContactType.id is 0. Is it necessary to call SubmitChanges after inserting the new ContactType, or am I missing something basic?
Dim ct As New ContactType
ct.name = "supervisor"
db.ContactTypes.InsertOnSubmit(ct)
Dim c As New Contact
c.ContactTy...
I have a combobox in my WPF app that is databound to my list of objects in my View Model. When the user makes changes to the selected object and then selects another item before saving, I need to clear the changes made.
I thought I could use dataContext.GetChangeSet().Updates.Clear() but for some reason the collection is read-only.
I'...
(Tried to post this on the ninject google group but it didn't show up so far, a few hours later..)
I have started using Ninject 2 (downloaded from Github yesterday including the MVC extension project) with a project based on the following technologies;
.Net 3.5 Sp1
ASP.NET MVC 1.0
LINQ to SQL
Nothing magical here - I have a few repo...
I want to do a JOIN with LINQ using an OR statement.
Here is the SQL query I'm starting with:
SELECT t.id
FROM Teams t
INNER JOIN Games g
ON (g.homeTeamId = t.id OR g.awayTeamId = t.id)
AND g.winningTeamId != 0
AND g.year = @year
GROUP BY t.id
I'm having trouble converting that ON clause to LINQ. This is where I'm at:
var...
In reporting tools like Crystal Reports, there are ways to take denormalized data and group it by a particular column in the data, creating row headings for each unique item in the specified column.
If I have this:
Category1 Data1
Category1 Data2
Category1 Data3
Category2 Data4
Category2 Data5
Category2 Data6
The re...
I have created a bass class in LinqToSql which has 2 sub-classes. I need to assign a different stored procedure to each of the sub-classes custom update methods. Doing this is fine, but I get an error of "Invalid object name 'xxx'".
e.g.
DataClasses1DataContext dc = new DataClasses1DataContext();
Class2 c2 = new Class2() { ID = 1, N...
I'm using the following code to insert a new entry in my existing db. But the new record doesn't get inserted. What are the options to fetch a possible exception?
What could be the reason that this doesn't work?
Thanks,
rAyt
using (ContactManagerSampleDataDataContext db = new ContactManagerSampleDataDataContext())
...
Hi, I'm trying to write some generic code in VB.NET that determines whether or not a SQL server database table contains an identity column and, if so, to return the name of that column.
I'm working in Visual Basic 2008 Express and have created a SQL database, "MyDatabase" with 1 table called "MyTable". Within that table, I've got 3 col...
How can I convert the following SQL statement into a LinqToSQL statement?
select field, 1 as ordering from table where field2 = condition1
union all
select field, 7 as ordering from table where field2 = condition2
union all
select field, 3 as ordering from table where field2 = condition3
union all
select field, 2 as ordering from table ...
if i have a field in my table that i want to verify exists, how do i use the contains method to determine if it exists.
i would have thought the contains method just takes in a string but it seems to take in my whole linq data object
...
Hi does someone know a quick way to find a class in large dbml files. We have a large data model and it takes a good 2-3 minutes to scroll and locate the required class. Zooming out makes it quite hard to see.
There has to be a better way than manually looking around
...
I have a UserController and an Edit.aspx. There is one field that is my primary key so i dont want to allow users to edit this field.
The issue is that if i remove the
<%= Html.TextBox("Email", Model.Email) %>
then when the asp.net-mvc magic calls my Controller code:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edi...
Hi all,
I have a simple problem that reads an Excel file (using interop) and fills an MSSQL database file with some data extracted from it. That's fine so far.
I have a Shops table with the following fields:
ID: int, auto-generated, auto-sync: on insert
Name: string
Settlement: string
County: string
Address: string
I read the excel ...
in the sql server database i have a field that is type "numeric". Precision is set to 18 in the database.
when i create a linq to sql class it comes up as this:
[Column(Storage="_zip", DbType="Decimal(18,0)")]
public System.Nullable<decimal> zip
{
Questions are:
do you know why it would choose to my it Decimal. this is obvious...