Possible Duplicate:
Nullable types and the ternary operator. Why wont this work?
This is my code which works
public decimal? Get()
{
var res = ...
return res.Count() > 0 ? res.First() : (decimal?) null;
}
and this one doesn't work
public decimal? Get()
{
var res = ...
return res.Count() > 0 ? res.First() : ...
Hello,
I'm new to linq and I'm trying to databind to an anonymous type.
I'm using SubSonic 3.0 as my DAL.
I'm doing a select from 2 tables like so
var myDeal = (from u in db.Users
select new
{
UserID = u.UserID,
UserRoleID = (from ur i...
I'm trying to take one attribute to use as the key, and another to use as the value. If I use (xDoc is an XDocument object in the example):
Dictionary<string, XElement> test = xDoc.Descendants()
.Where<XElement>(t => t.Name == "someelement")
.ToDictionary<XElement, string>(t => t.Attribute("myattr").Value.ToString());
I get a ...
Hello all, I am working on an ASP.net page that also users ChartFX. I need to pull a row from a database table and then flip it so that all of the labels for the row are in a column and all of the data from the row is in a parallel column to the labels.
I would really like to do this using LINQ and then create a table in memory to store...
I want to get all records WHERE (s.override == 1 OR (s.override == 2 AND s.approved == 1))
How can I do that using the .Where x.subcontracts.Where(s ==> ??)
...
I want to replicate this query in LINQ to SQL but am too unfamiliar with how to do it.
SELECT A.Recruiter, SUM(O.SaleAmount * I.Commission) --This sum from fields in two different tables is what I don't know how to replicate
FROM Orders AS O
INNER JOIN Affiliate A ON O.AffiliateID = A.AffiliateID
INNER JOIN Items AS I ON O.ItemID = I.I...
Hello,
is it possible to change the foreign key relationship object naming of LINQ to SQL generated objects?
For example, I have a Demo table which has the fields ItemMinId, ItemMaxId, ItemExlId which are all foreign key references to my Item table.
LINQ generates now Demo.Item, Demo.Item2, Demo.Item3 fields which makes it difficult in...
I've reached the end of my Linq rope. Need your help!
Heres my table structure first(all linq to sql objects):
InventoryItems
-ID
-AmtInStock
IventoryKits
-ID
InventoryKits_to_InventoryItems
-InventoryItemID
-InventoryKitID
So i need to do a projection like the following
var q2=from k in GetAllKits()//returns IQueryable...
Hello,
is it possible to decorate a field of a LINQ generated class with [Column(IsDbGenerated=true)] using a buddy class (which is linked to the LINQ class via [MetadataType(typeof(BuddyMetadata))]) ?
My goal is to be able to clear and repopulate the LINQ ORM designer without having to set the "Auto Generate Value" property manually ev...
This is a basic question. I have the basic SL4/RIA project set up and I want to create a new method in the domain service and return some data from it. I am unsure the proper easiest way to do this.. Should I wrap it up in a ToList()? I am unclear how to handle this anonymous type that was create.. what is the easiest way to return this ...
I have the following subsonic entities
TInvoiceHeader
TAccountAssociation
How can I achieve the following in LINQ (subsonic)
SELECT * from TInvoiceHeader
WHERE custid IN
(SELECT custid FROM TAccountAssociation
WHERE username = 'a')
I need to bind the results to a GridView.
Update: I tried
Dim accounts As List(Of TAccountA...
Suppose I have a class
public class Foo
{
public Bar Bar { get; set; }
}
Then I have another class
public class Gloop
{
public List<Foo> Foos { get; set; }
}
What's the easiest way to get a List<Bar> of Foo.Bars?
I'm using C# 4.0 and can use Linq if that is the best choice.
UPDATE:
Just for a little dose of reality, the ...
hello
What is difference between of these 2 queries ? they are completely equal ?
from order in myDB.OrdersSet
from person in myDB.PersonSet
from product in myDB.ProductSet
where order.Persons_Id==person.Id && order.Products_Id==product.Id
select new { order.Id, person.Name, person.SurName, product.Model,UrunAdı=produc...
i am saving dafault values in an xml file. if i dont have access to the xml file i should show message in the status bar
...
class Test {
int Id{get;set;}
string Name {get;set;}
string Description {get;set;}
}
//1)ok
context.Tests.Select(t => new {t.Id, t.Name}).ToList().Select(t => new Test{Id = t.Id,
Name = t.Name});
//2)ok
class TestPart{
int Id{get;set;}
string Name {get;set;}
}
context.Tests.Select(t => new TestPart{Id = t.Id,
Name = t.Name...
The lack of expression trees in Compact Framework has bugged me for some time now, but I haven't really looked for a solution.
Today, I've found a blog post about an alternative System.Linq.Expressions built on top of Mono System.Core and used e.g. by db4o (you can find it here).
My question is - have you used this library and if so,...
i have one default.xml file where i am storing all default values.suppose if invalid file with the same default.xml name exists i have to display message in the status bar.
...
IEnumerable<String> existedThings =
from mdinfo in mdInfoTotal select mdinfo.ItemNo;
IEnumerable<String> thingsToSave =
from item in lbXReadSuccess.Items.Cast<ListItem>() select item.Value;
Here are two IEnumerable.
I want to check whether a value in existedThings exist in thingsToSave.
O.K. I can do that with 3 li...
Hi
Based on this question:
http://stackoverflow.com/questions/3013034/what-is-difference-between-where-and-join-in-linq
My question is following:
Is there a performance difference in the following two statements:
from order in myDB.OrdersSet
from person in myDB.PersonSet
from product in myDB.ProductSet
where order.Person...
Can someone tell me what I'm doing wrong with the following Linq query? I'm trying to find the directory with the highest aphanumerical value.
DirectoryInfo[] diList = currentDirectory.GetDirectories();
var dirs = from eachDir in diList
orderby eachDir.FullName descending
...