I am trying to select rows from a table where one of the (NVARCHAR) columns is within a numeric range.
SELECT ID, Value
FROM Data
WHERE ISNUMERIC(Value) = 1 AND CONVERT(FLOAT, Value) < 66.6
Unfortunately as part of the SQL spec the AND clauses don't have to short circuit (and don't on MSSQL Server EE 2008). More info: http://stackover...
I recently switched from using Linq to Sql to the Entity Framework. One of the things that I've been really struggling with is getting a general purpose IQueryable extension method that was built for Linq to Sql to work with the Entity Framework. This extension method has a dependency on the Like() method of SqlMethods, which is Linq to...
Hi,
I would like to know if its possible to discard changes of only one record of only one table in datacontext.
I use databind to bind my controls on a form. I modify one record at a time. after the modification, the user have to hit save button to validate. But he can hit cancel. I would like that the cancel button discard all the ch...
public IQueryable<ArticleDisplay> SearchNumberOfArticles(int articleNr, string order)
var result = (
from category in db.ArticleCategories
join article in db.Articles on category.CategoryID equals article.CategoryID
orderby article.Date order
...
I have a deeper question regarding debug functionality of Linq to Sql SubmitChanges() Function.
I want to save a record in a table of a locally cached db (localdbcache: server SqlExpress 2008 client SqlCE). Before calling SubmitChanges I can find the new item via DataContext.GetChangeSet(). After calling Submit Changes, the items to ins...
I have a data structure where an entity has times stored as an int (minutes into the day) for fast comparison. The entity also has a Foreign Key reference back to a TimeZone table which contains the .NET CLR ID Name and it's Standard Time/Daylight Time acronyms.
Since this information is stored as time-zone insensitive - I was wonderin...
Im making this method retrieve records from the Data Base. As you can see i Want to return a List where ITieneID is an Interface defined on my business layer.
AtlasWFM_Entities.Clases.Area implements that interface. It is pretty clear that this is not a good way to accomplishing it (even though it compiles correctly)
public override L...
I have two tables with a weak relation.
I need get a text value from one table using a key from another.
I am using the following C# LINQ code:
City = rea.tRealEstateContact.tPostnumre != null ? rea.tRealEstateContact.tPostnumre.Bynavn : string.Empty
But when the key cannot be found in the table 1(tPostnumre), an exception is thrown.
...
I just ran into something in Visual Studio 2010 RC that wasn't previously happening (like, yesterday). No software changes here, but I did run into some muck yesterday when compiling that required a reboot.
I am unable to add LINQ to SQL classes to any project through the add dialog. I have created ASP.NET web sites, ASP.NET MVC projec...
Hi, im trying to do a join in linq , however for some reason i cant access the primary key of a table. It's the 'h.ProjectId' that doesn't seem to be accepted.
The following error is given
CW1.SearchWebService.Bid does not contain a definition for 'ProjectId' and no extention method 'ProjectId' accepting a first argument of type 'CW1Se...
Given the following database structure
I'm trying to write a LINQ query that will return images grouped by tags it's associated with. So far I've got this:
var images = from img in db.Images
join imgTags in db.ImageTags on img.idImage equals imgTags.idImage
join t in db.Tags on imgTags.idTag equals t.idTag
where img.OCRDa...
I have a table with the below structure.
ID VALUE
1 3.2
2 NULL
4 NULL
5 NULL
7 NULL
10 1.8
11 NULL
12 3.2
15 4.7
17 NULL
22 NULL
24 ...
I have a table Users and a table Items
In the Items table, I have fields such as
ModifiedBy
CreatedBy
AssignedTo
which all have a userId integer. The database is set up to have these as foreign keys back to the Users table.
When using LINQToSQL, the relationships which are automatically built from the dbml end up giving me names li...
I'm trying to do the following:
from c in db.GetAllContactsQuery()
select new
{
ID= c.ID,
LastName = c.LastName,
FirstName = c.FirstName,
Email = c.Email,
City =c.City+" "+c.State
}
The issue i'm running into is that if c.City or c.State are null, the City property returns null. How can I put a function right beside tha...
Hi,
I'm using LINQ to SQL to select some columns from one table. I want to get rid of the duplicate result also.
Dim customer = (From cus In db.Customers Select cus.CustomerId, cus.CustomerName).Distinct
Result:
1 David
2 James
1 David
3 Smith
2 James
5 Joe
Wanted result:
1 David
2 James
3 Smith
5 Joe
Can ...
I have a requirement to have a multiline textbox that accepts any text from any language and stores this into the database for later use.
I am using Linq with ASP .NET 3.5 with a SQL Server 2005 database.
Any/all information you can provide me with is much appreciated :D
...
I am trying to get my linq query to replicate my t-sql but I am lost.
SELECT *
FROM BaiDetail INNER JOIN
BaiDetailMap ON BaiDetail.DetailText
LIKE '%' + BaiDetailMap.BaiDetailMapSearchText +'%'
This is what I have so far... but no go
from det in Source
from map in Map
where det.DetailText.Contains(map.SearchText)
select ne...
Hello,
I have a grid (DevExpress XtraGrid, if that matters) which is bound to a LINQ to SQL Entity property.
gridItems.DataSource = purchaseOrder.PendingItemsGrouped;
Well, the grid is being displayed properly,and I can see the purchase items that are pending.
The problem arises when purchaseOrder.PendingItemsGrouped gets changed ......
Am I doing something wrong if I need code like this in a Controller? Should I be doing something differently?
public ActionResult Details(int id)
{
var svc = new ServiceClient();
var model = new MyViewModel();
model.ObjectA = svc.GetObjectA(id);
model.ObjectB = svc.GetObjectB(id);
model.ObjectC = svc.GetObjectC(id);
...
I'm just getting started with ASP.NET MVC, mostly by reading ScottGu's tutorial. To create my database connections, I followed the steps he outlined, which were to create a LINQ-to-SQL dbml model, add in the database tables through the Server Explorer, and finally to create a DataContext class.
That last part is the part I'm stuck on. I...