I have the following LINQ code:
docTypes = (from c in context.Citizenships join
cdt in context.Citizenship_Document_Types
on c.Country_Code equals cdt.Country_Code
from cd in context.Citizenship_Documents
.Where(cd => cd.Citizenship_Id == c.Citizenship_ID)
...
I currently have many linq expressions nested within foreach loops ... kind of defeating the point of using linq!
What I'm trying to achieve is a simple blog model (blog posts which have multiple tags and are associated with multiple categories... that's all).
I'm looking for a way to condense all my linq expressions into a single expr...
I am always finding myself creating linq expressions that still use nested foreach loops heavily. Below is a simple example of what I'm talking about, and I'd really appreciate it if someone on here can show me how to condense this low-efficiency code into a single linq expression?
The database context (db) has three tables: Blog, Tag, ...
I'm trying to modify some code that returns results from the database. Currently the code is as follows, and matches whatever funds have a name like the search term.
var ret = (from funds in queryable
where
SqlMethods.Like(funds.Name, searchTerm)
select
fund...
Can you help me with next: I'd like to add variable count of SqlMethods.Like() in one query?
For example: I've four words in list catCode, how can I create LINQ query with four SqlMethods.Like()?
using (var db = new MappingDataContext(_connection))
{
db.ObjectTrackingEnabled = false;
return (
from r in db.U_CDW_REPORTs...
Hi,
How can I write the linq query to check DateOfBirth is between given date.
...
I know this looks a bit long but i tried to explain the problem as throughly as i could.
We are having a very 'exotic' problem with the linq to sql data context class. We have a n-tiered architectured structured like this: We have 3 classes MotherClass, ChildClass, ChildChildrenClass
MotherClass looks something like this:
public class...
I have a Client entity and PostCode entity in Linq to SQL model. The Clients table in database contains client_postcode column which is a FK column to postalcode column in PostCode table, which is a varchar column primary key for PostCode table.
When updating Client, in my code I do this
// postcode
updating.PostCode =...
var query_loc = (from at in db.amenities_types
join a in db.amenities on at.id equals a.amenities_type
join u in db.unitInfos on a.unit_id equals u.id
join l in db.locations on u.locations_id equals l.id
join o in db.organizations on l.organization_id eq...
So I have Projects (for this example say they are a Name and an ID). I also have a table called SubProjects, like this:
MasterProjectID SubProjectID
1 2
1 3
4 5
4 6
4 7
A master cannot be a sub of another master.
I want to retu...
Hi,
I am using ASP.NET Dynamic Data Entities project to generate a web application for my database. I was wondering what is the easiest way to restrict the allowed values for a column without changing the database structure to make that column a foreign key or modifying the database in any way.
For example. I have a table called Assets...
In a LINQ To SQL query, how can I apply a Round function on a column in my output?
My query is
From s In oRecelDB.Items Where s.BIN = 'ABC' Select s.ITEMNMBR, s.QUANTITY
and the results are
ITEM I 35.0000
ITEM 2 45.0000
ITEM 3 23.0000
I want to remove the .00000 from the Second column value. How to do that in my query?
...
Possible Duplicate:
Exclude complete namespace from FxCop code analysis?
I'm running FxCop as a post-build step of my class library project and it's picking up violations from the LINQ-to-SQL generated code.
I am running FxCop as follows (line breaks added for clarity):
<PostBuildEvent>
"$(SystemDrive)\Utils\DeveloperTools...
hi there
i am trying to build up a string containing the values of fields in a linq to sql object.
the thing is, i only want to grab the fields that are not null
i am sure there is a way to do this.
can anyone enlighten me?
mylinqdatacontext dc = new mylinqdatacontext;
StringBuilder sb = new StringBuilder();
mylinqtype item = (from x...
Hi,
I am working on a Webforms app (in VS 2010, .net 4.0, VB) that uses SQL2008, Linq2Sql, Domain Services and Dynamic Data.
My problem is that when I try to insert a new record, I get the error: "..CustomerId is required"
but the ID is set as primary key and Identity in the database and the Customer entity in the L2S Datamodel is also...
I have multiple Linq2Sql Classes such as "Article" "NewsItem" "Product".
They all have a title, they all have a unique ID and they all have a Summary.
So, I created an interface called IContent
public interface IContent {
int Id { get; set; }
String Title { get; set; }
String Summary { get; set; }
String HyperLink { ge...
Is the VS 2008 professeional Edition fully support with linq to sql
Thank
...
Hello,
I've been trying to implement a custom ORM for our project and am interested to learn how LINQ to SQL or Entity Framework lazy load objects.
I read some about EntitySet and realized it has a Load() method. Does anyone know how exactly Load works? I'm assuming it should have a reference to DataContext (or ObjectContext in EF) t...
hI..!
Dim query = From c In cntxtNorthWind.Customers _
Join x In cntxtNorthWind.Orders On c.CustomerID Equals x.CustomerID into sr _
from b in sr.DefaultifEmpty() _
Select c.CustomerID, x.OrderID, x.ShipAddress
Above Outer Left Join cannot execute it's says "End of Statament Expected"
...
How to Prevent Null Value's return in Linq
...