Good Morning,
I have created a structure to be a cut down version of a Class that I already have.
I am trying to use a linq query to iterate through the list of MyClass and create a List based on the results (A discinct list based on a few of the properties on MyClass). Something like this...
List<MyStructure> thisList = (from MyClas...
I have an entity object (Company) which has 1 or more subobjects (CompanyRevision) represented as a non-null FK relationship in the database.
Using LINQ, I want to get all the Companies from the database, but I also only want the latest CompanyRevision for each company.
This is how I do it today, but I have a feeling this could be done u...
I have a master-detail tables and I want to get list of master join with detial where detail is max in some filed.
for example I have a table named Document and also a child table named Revision .I want to get list of document join Revision where Revision filed is max
?
One solution is:
using ( ProcurementDataContext dc = new Procurem...
When i use the results of a linq-to-xml query to populate a datagridview, i cannot edit the datagridview. i've tried setting the datagridview's readonly property to false and that doesn't help. I also added an event handler for cellBeginEdit and put a breakpoint there, but it doesn't get hit. Any idea what i'm doing wrong, or if this ...
We've got a Class called Group, it contains a collection of questions and it also contains collection of groups (i.e. we have a potential nesting of groups).
Expressed in XML this might look something like this:
<group id="Group1">
<questions>
<question id="questions11"/>
</questions>
<groups>
<group id="group12">
...
In the code bdehind && syntax does not work, any ideas?
Entities ctx3 = new Entities();
var uniqueQuote = from quot in ctx3.Quotes.Include("aspnet_Users").Include("Enquiries")
where quot.Enquiries.EnquiryId == selectedEnquiryId &&
quot.aspnet_Users.UserId == currentUserId
orderby quot.QuotePrice
select quot;
Error 2 Del...
Hello,
I am sure this is something really simple, but I am going bonkers trying to figure out why.
I have the following code:
string condition = string.Format("{0}.Contains({1})", column, value);
var query = DataContext.MyTable.Where(condition);
The strange thing that I am getting is an error saying:
Argument cannot convert from s...
Hey guys, new to WPF and really struggling with 'the right way' to do things...
public void Save(CompanyContact entityToSave)
{
try
{
var saveEntity = (from cc in db.CompanyContacts
where cc.CompanyContactId == entityToSave.CompanyContactId
select cc).SingleOrDefault();
if (saveEntity == null)
{
/...
Hi,
I'm using the microsoft EdmGen2 to generate my edmx file from my database. The tool works great, but there is one things missing - it doesn't support function. Is there a way to map all the stored procedures to be functions?
Also, if i'm editing it manually, the next time im running this tool, i'm losing all those changes.
my ques...
I have a Dictionary
private readonly Dictionary<int, BinaryAssetExtensionDto> _identityMap;
And I would like to do something like this:
if(_identityMap.Values.Contains(x => x.extension == extension))...
Is this possible because previous code doesn't work.
Now I'm doing it like this:
var result = _identityMap.Values.ToList().Find(...
Hey,
I'm trying to convert some SQL I've patched together into a LINQ query.
The context is a simple quiz app. A quiz has quizrounds, contestants are one to one attached to quizrounds, rounds have registered answers.
The case is that I have a one to many relationship between tables 'quizround' and 'answer'.
I want to do a ranking of a...
Hello,
I set an object entity with a stored procedure, but the navigation properties are always equals at null ...
The aim is to include or join an external entity.
Any idea ?
Thanks
...
Hi
I can build up a sql string by concatenating a string i.e.
String fieldname =”Company”;
String tableName= “Address”;
“select “+fieldname+” from “+tableName
How can I do this with Linq?
TIA
Stuart
...
Hi i have a model where i have to count the rows with conditions:
uscitaservizio == false and accountid attribute (int) is in a string filtrodipe
es: filtrodipe = "2,4,5,6"
I' ve tried with this:
db.TDP_Missioni.Count( p => p.UscitaServizio == false &&
(objUser.FiltroDipe != null ? (p.AccountID.ToString() in objU...
If I have Table3 that has a FK pointing to Table2 which has a FK pointing to Table1 what I'm seeing via intellisense is I can reference Table2 from Table3 but I can't go Table3.Table2.Table1 it only goes one layer deep.
from t3 in Table3
where t3.t2.property == "some value" && t3.t2.t1.property == "some other value"
select t3.t2.t1;
T...
In our application we have a little query that looks like this:
var selectedAgents = from agent in listAgents
where (this.collectionVehicles.GetVehicleByAgent(agent)).IsActive ||
(this.collectionVehicles.GetVehicleByAgent(agent)).IsSoldSinceCurrentSession
select agent;
This works fine but the method GetVehic...
I start with a basic class that I want to manipulate in a List using LINQ, something like the following:
public class FooBar
{
public virtual int Id { get; set; }
public virtual string Foo{ get; set; }
public virtual string Bar{ get; set; }
}
This is what I ultimately found out to solve my problem using the non ...
I'm playing with QuickSort and LINQ, and want to separate the sequence into item before, equal-to, and after a pivot.
Here's what I have so far:
public static Tuple<IEnumerable<T>, IEnumerable<T>, IEnumerable<T>> ComparativeWhere<T>(this IEnumerable<T> source, T t)
where T : IComparable<T>
{
return new Tuple<IEn...
Here's my problem: I have an IPerson which is implemented by Employee and Student. What I really want is what you see below. One LINQ statement to get each type of IPerson. This works great until I call the method ;). It makes sense as to why I'd get the error, but I am really struggling as to find a decent way to pull all IPerson o...
I have the following query
Dim get_rmf_2 = From rmf In t_rmf _
Where rmf!NIVP = nivp_rap
When i run it i get an error :
Operator '=' is not defined for type 'DBNull' and string "test".
I suspect this is because the column "NIVP" in the datatable contains null values, I've tried yhe same thing without null values and it works...