I have the following SQL which I am trying to translate to LINQ:
SELECT f.value
FROM period as p
LEFT OUTER JOIN facts AS f ON p.id = f.periodid AND f.otherid = 17
WHERE p.companyid = 100
I have seen the typical implementation of the left outer join (ie. into x from y in x.DefaultIfEmpty() etc.) but am unsure how to introduce the oth...
Is it possible to use LINQ to retrieve a list that may contain nulls.
For example if I have a left outer join like so:
var query= from c in db.Customers
join o in db.Orders
on c.CustomerID equals o.CustomerID into sr
from x in sr.DefaultIfEmpty()
select x.OrderId;
Ho...
Hi i was wondering if you have had seen a quick demo on creating a LINQ Provider.
Thanks,
Oscar
...
I always wondered why there's an equals keyword in linq joins rather than using the == operator.
Property deadline =
(from p in properties
join w in widgets
on p.WidgetID equals w.ID
select p).First();
Instead of
Property deadline =
(from p in properties
join w in widgets
on p.WidgetID == w.ID
select p).First();
[EDIT] Rephra...
I have tables Users, Widgets and Layouts. Users have many-to-many relationship with Widgets via Layouts. Each Layout has UserID and WidgetID. I want to delete a Layout that matches specific UserID and WidgetID.
Using SubSonic 3 ActiveRecord I write:
Layout.Delete(x => x.UserID == user.id && x.WidgetID == id);
However, SubSonic delete...
Hi folks,
I've got the following code in my Services project, which is trying to grab a list of posts based on the tag ... just like what we have here at SO (without making this a meta.stackoverflow.com question, with all due respect....)
This service code creates a linq query, passes it to the repository and then returns the result. N...
hi,
been taxing my brain trying to figure out how to perform a linq xml query.
i'd like the query to return a list of all the "product" items where the category/name = "First Category" in the following xml
<catalog>
<category>
<name>First Category</name>
<order>0</order>
<product>
<name>First Product</name>
<...
In a LINQ to entities expression like this:
var vote = (from vote in db.Vote where
vote.Voter.Id == user.Id
select v).FirstOrDefault();
how do you you add a DefaultIfEmpty so that when there's no vote I'd get a default value?
...
I asked this question earlier but I think I phrased it incorrectly, so here is attempt number two. I have the following code:
public User EditUser(User userToEdit)
{
//userToEdit contains values for eagerly loaded contacts entity
User originalUser = (from u in _entities.UserSet.Include("contacts")
...
I just started learning Silverlight, and I'm wondering about the typical architecture of a Silverlight application and the workflow in the application (I'm using Silverlight 2, but will move to 3 any time soon).
In my test-application I currently only have the two default projects - MyProject and MyProject.Web. I'm familiar with the MV...
Hello I have a problem with Skip function.. I code I have for fetching data is
db_stamperDataContext context = new db_stamperDataContext();
//var modifier = (from m in context.Modifiers
// where m.Modifier1 == "Public"
// select m).First();
//var item = from p in context.It...
We are currently using SubSonic 3.0.0.2 and playing about with the Linq for it, we've noticed that the underlying SQL is not parameterized.
I'm aware that the query tool is and we can work with that but I'm just curious if having parameterized with Linq is possible?
Am I missing something? or is this not yet implemented in SubSonic.
...
Hi All,
I just want to know what's the lambda expression of Select * from TableName.
Like in plain LINQ it will be var res=from s in db.StudentDatas select s;
here StudentData is name of the table.
Thanks.
...
Greetings! I want to use LINQ to query a list of objects and sort them by an enumeration value, string value then union the rest of the list sorted in a similar fashion LINQ newbie here, so be gentle.
//CTOR for my class
MyClass(id, "Name Value Here", Enum.EnumValueHere);
I create a list of these objects and want to variably sort th...
Is it just me or does changes produced by refreshing the LINQ DataContext not result in Changed Events?
I have a multiuser Application which has an simple atomar locking system to prevent conflicts.
So if an User changes something in the database I need to trigger Refresh on the Datacontext to reload the concerning objects.
A breakpoin...
Hello there,
i have a class user, and i also have implemented a collection for the same user class - users. users will store user objects. users collection class implements the generic collection class - collection.
i want to cast the LINQ query result into an object of my collection class - users. Everytime i try explicit casting, it ...
So I wrote this simple console app to aid in my question asking. What is the proper way to use a lambda expression on line 3 of the method to get the common members. Tried a Join() but couldn't figure out the correct syntax. As follow up... is there a non-LINQ way to do this in one line that I missed?
class Program
{
static void Mai...
I have a set of strings. I want to select all strings that contains another string. But I want to have as the first items, the items that start with the search, and then, alphabetically the other items. But the following code doesn't work:
items = items
.Where(a => a.Contains(contained))
.OrderBy(a => a)
;
var startsWith = item...
The function in dbml is,
[Function(Name = "dbo.sp_GetQuestions")]
public ISingleResult<vw_QuestionMaster> sp_GetQuestions([Parameter(Name = "Sort", DbType = "Int")] System.Nullable<int> sort, [Parameter(Name = "Title", DbType = "VarChar(50)")] string title, [Parameter(Name = "Tags", DbType = "VarChar(50)")] string tags, [Paramet...
EDIT: During this post I started
searching on video tutorials on
ASP.NET MVC, EF and LINQ and found
some very useful links which I shared
here. As I believe videos are more
interactive and easier to learn from.
Hope, they'll help.
Guys, please share the resources to get start on MVC, Entity Framework and LINQ. And if you...