LINQ query null reference exception
Hi! I have the next query: var bPermisos = from b in ruc.Permisos where b.IdUsuario == cu.Id select new Permisos(){ Id=b.Id, IdUsuario=b.Id, IdPerfil=b.Id, Estatus=b.Es...
Hi! I have the next query: var bPermisos = from b in ruc.Permisos where b.IdUsuario == cu.Id select new Permisos(){ Id=b.Id, IdUsuario=b.Id, IdPerfil=b.Id, Estatus=b.Es...
I have two list of members like this: Before: Peter, Ken, Julia, Tom After: Peter, Robert, Julia, Tom As you can see, Ken is is out and Robert is in. What I want is to detect the changes. I want a list of what has changed in both lists. How can linq help me? ...
Hey guys Just wondering how the following sql query would look in linq for Entity Framework... SELECT KPI.* FROM KeyPerformanceIndicator KPI INNER JOIN ( SELECT SPP.SportProgramPlanId FROM SportProgramPlan PSPP INNER JOIN SportProgramPlan ASPP ON (PSPP.SportProgramPlanId = @Sport...
I think I need a way to perform a pivot or crosstab using C# and Linq with an indeterminate number of columns. However, I will add some beginning detail to see where it goes. < Beginning detail > Imagine a table that has two fields: string EventName; Datetime WhenItHappend; We want to generate a report like the example below where ...
Hi, i am trying to get some data, but i dont know how can i do a if in linq, this is how i am trying to do from so in db.Operations where ((opType!= "0" ? so.Operation == int.Parse(opType) : false) && (idState!=0 ? so.State == idState : false) && (start != null ? so.StartDate == start : false) && (end !=null ? so.EndDate ...
Hello Everyone, I am using LINQ and I was wondering what is the best way to create an XDocument and then check to make sure that the XDocument actually exists, much like File.Exists? String fileLoc = "path/to/file"; XDocument doc = new XDocument(fileLoc); //Now I want to check to see if this file exists Is there a way to do this? Th...
<Party id="Party_1"> <PartyTypeCode tc="1">Person</PartyTypeCode> <FullName>John Doe</FullName> <GovtID>123456789</GovtID> <GovtIDTC tc="1">Social Security Number US</GovtIDTC> <ResidenceState tc="35">New Jersey</ResidenceState> <Person> <Firs...
whats the correct way to cache a object(DataSet) and then get it and when it expires repopulate it with out a major hiccup in the application... the application relies on this data to be there for read only purposes. ...
Hi, I have a Db server with DateTime fields in the format of "yyyy-MM-dd mm:hh:ss" I'm trying to use linq2sql to insert a DateTime member to a DateTime field in one of my tables. When I do it in SQL I convert the DateTime as following: "Insert into .... Convert(datetime, getdate(), 120) ..." But when I try to submit the object from Linq ...
I'm using LINQtoSQL and I want to return a list of matching records for a CSV contains a list of IDs to match. The following code is my starting point, having turned a CSV string in a string array, then into a generic list (which I thought LINQ would like) - but it doesn't: Error Error 22 Operator '==' cannot be applied to operands of ...
what would be the difference between this class Class1 { public string prop1 { get; set; } public string prop2 { get; set; } public string prop3 { get; set; } public string prop4 { get; set; } } and this class Class2 { public string var1; public string var2; public string var3; public string var4; } ...
Hi all, I am writing an app for my company and am currently working on the search functionality. When a user searches for an item, I want to display the highest version (which is stored in a database). The problem is, the version is stored as a string instead of int, and when I do an OrderBy(q=>q.Version) on the results, they are retur...
The code below is designed to take a string in and remove any of a set of arbitrary words that are considered non-essential to a search phrase. I didn't write the code, but need to incorporate it into something else. It works, and that's good, but it just feels wrong to me. However, I can't seem to get my head outside the box that thi...
Hello all, I'm having a problem using UpdateModel(theModelToUpdate) causing concurrency issues. Basically whats happening is, there is a row in the database that contains most but not all the information needed for that row. The rest of the needed information is NULL. The user (using a listbox) would then add information to this row, a...
I'd like to add the "msdb.dbo.sp_help_job" system stored procedure to a LINQ to SQL object, but I can't figure out how to specify it. If I create a new Data Connection in Server Explorer and specify the "msdb" database of the server I want, and navigate to "Stored Procedures", that procedure is not listed. Am I looking in the wrong place...
THIS WORKS! .. but still needs one more thing... Okay, so this is both a "comment" and question. First, is the working example that may help others in search of a asp.net webmethod / jqGrid approach. The code below completely works for sending/receiving JSON parameters from and to jqGrid in order to have correct paging, sorting, filteri...
My xml looks like: <nodes> <node name="somekey"> <item name="subject">blah</item> <item name="body">body</item> </node> </nodes> And my code so far is: XDocument doc = XDocument.Load(HttpContext.Current.Server.MapPath(String.Format("~/files/{0}/text.xml", "en"))); if (doc != null) { XElement element = doc.Elements().Where(e => e...
I'm having trouble translating an existing TSQL query with a "Not Exist" clause into working LINQ for use in an ASP.NET MVC app. Here's my existing query. SELECT OrgID, ContentID, FriendlyTitle FROM ContentRollup CR WHERE OrgID = @sOrgID OR ( OrgID = '*' AND NOT EXISTS ( SELECT ...
is there any way to write this foreach in linq or another better way, int itemNr = -1; foreach(ItemDoc itemDoc in handOverDoc.Assignment.Items) { itemNr++; foreach(ItemDetailDoc detail in itemDoc.Details) { int eventDocNr = -1; foreach(EventDoc eventDoc in detail.Events) { eventDocNr++; ...
var expr = Data.Customers .GroupBy(c => c.Country, c => c.Name); foreach (IGrouping<Countries, string> customerGroup in expr) { Trace.WriteLine("Country: " + customerGroup.Key); foreach (var item in customerGroup) { Trace.WriteLine(item); } Trace.Wri...