This should be REALLY simple but I can't figure it out.
I can bind the data to a datagrid like this below...
var context = new DishViewDomainContext();
this.dataGrid1.ItemsSource = context.Restaurants;
context.Load(context.GetRestaurantsQuery());
. That works... But now I just want that collection in a variable that I can loop thro...
Back in late 2008 there was a lot of debate about the future of LINQ to SQL. Many suggested that Microsoft's investments in the Entity Framework in .NET 4.0 were a sign that LINQ to SQL had no future. I figured I'd wait before making my own decision since folks were not in agreement.
Fast-forward 18 months and I've got vendors providi...
Hi!
I have the following code in Linq to Entity:
var policy= from pol in conn.Policy
where pol.Product.DESCRIPTION=="someProduct"
SELECT pol;
Then, the table Policy, has some dependencies for a table called Entity. If I do this:
foreach(Policy p in policy){
if(!p.Entity.IsLoaded) p.Entity.Load();
IEnu...
I need to be to create an entity data model in the EF version 1, because my web host doesn't have Framework 4.0 yet. Below is just a simple example to show the problem.
I have 3 tables, one Users table, another Webpages table, and one table with Visits. The former two tables each have a one-to-many relationship with the Visits table (w...
We have a project using LINQ to SQL, for which I need to rewrite a couple of search pages to allow the client to select whether they wish to perform an and or an or search.
I though about redoing the LINQ queries using PredicateBuilder and have got this working pretty well I think. I effectively have a class containing my predicates, e....
Hi,
I use C# 3.5 DotNet Framework and Linq.
I have 2 Views which have the same result-schema, but in linq that are different objects of course.
How can I convert List a to List b?
...
This code give me an error:
string rus = "," + db_user.Anagrafica_Dipendente.ID_Dipendente + ",";
int i = db.CBR_User.Count(
p => p.RiceviMail == true && ("," + p.Dipe + ",").Contains(rus))
p.Dipe is a string
the error is:
Unable to create a constant value of type 'System.Object'.
Only primitive types ('such as Int32, String, an...
I am asking my self many times before start writing a new app or data access library , should I use LINQ to SQL or classic ADO.net , I have used both and the development time I spend on building an app with LINQ to SQL is like the 1/3 compared to ADO.net.
The only think I like using LINQ to SQL is that I don't have to design the domain ...
The below code will fill User Records in "users".
Dim users= From p In oDbUser.USERs Where p.STATE= "MI" And p.STATUS = 1
Can anyone tell me how can i use a foreaach loop in the result and take each indidual row items ?
...
Do not expose generic lists
IF all my methods, need to expose a collection, then I need to user the Linq Extension .ToList(), almost everywhere I need to use lists, or user Collections in all my code.
If that’s the case, .ToList() is ignoring the rule right? Or is there a technique like copying the list o something to fix the violation...
I have view with the following which works:
<%= Html.TextBoxFor(m => m.FirstName, new { @class = "required_field_light" }) %>
<%= Html.ValidationMessageFor(m => m.FirstName) %>
However, if I change the ValidationMessageFor() to a ValidateFor() like this:
<%= Html.ValidateFor(m => m.FirstName) %>
I get this compile error:
"The best...
I have a list that I need sorted by two fields. I've tried using OrderBy in LINQ but that only allows me to specify one field. I'm looking for the list to be sorted by the first field and then if there are any duplicates in the first field to sort by the second field.
For example I want the results to look like this (sorted by last na...
What is in and not in equals in LINQ to SQL?
For example
select * from table in ( ...)
and
select * from table not in (..)
What is equal to the above statement in LINQ to SQL?
...
Ok, so I have a table
Table:
Id
Value
If I query my table and group my result by "Value" how can I make it so each of the groups are alphabetized (a group grouped by a "Value"="a" will come before a group grouped by a "Value" = "z").
My current query looks something like this:
var Result =
from a in DB.Table
orderby a.Value
group by...
I have been getting the following exception:
The binary operator GreaterThanOrEqual
is not defined for the types
'System.Nullable`1[System.DateTime]'
and 'System.DateTime'.
I am getting the left hand expression from a class property which is a nullable datetime variable and my right hand side is using
Expression.Constant(new...
I have the following Linq query:
from workItem in WorkItem
join workItemHistory in WorkItemHistory on workItem equals workItemHistory.WorkItem
join ivSweepHistory in IVSweepHistory on workItemHistory equals ivSweepHistory.WorkItemHistory
where workItem.SerialNumber == "080106081985"
orderby ivSweepHistory.ReadTime descen...
How would you obtain the min and max of a two-dimensional array using LINQ? And to be clear, I mean the min/max of the all items in the array (not the min/max of a particular dimension).
Or am I just going to have to loop through the old fashioned way?
...
Given an
Expression<Func<T, object>>
(e.g. x => x.Prop1.SubProp), I want to create a string "Prop1.SubProp" for as deep as necessary.
In the case of a single access (e.g. x => x.Prop1), I can easily do this with:
MemberExpression body = (expression.Body.NodeType == ExpressionType.Convert) ? (MemberExpression)((UnaryExpression)expr...
Im trying to convert a SQL join to LINQ. I need some help in getting the nested join working in LINQ.
This is my SQL query, Ive cut it short just to show the nested join in SQL:
select distinct
txtTaskStatus as TaskStatusDescription,
txtempfirstname+ ' ' + txtemplastname as RaisedByEmployeeName,
txtTaskPriorityDescription as...
I am using LINQ expressions in my code
like this
var obj = Collection.Single(collection => (collection.ShortName.Equals("AAA")));
The problem is that this line works fine for me, no problems.
But when I upload the same executable to some remote machine with same 32 bit Windows XP. The code execution is just stopping at this line of s...