79 Topics

Member Avatar for
Member Avatar for Rushabh Verma

I created a worked sql query: select CONVERT(date, C.tDate) as dt, count(O.Id) as cnt from [Calendar] C left outer join [Order] O on C.tDate = CONVERT(date, O.Dt) group by CONVERT(date, C.tDate) order by CONVERT(date, C.tDate) And I want to rewrite it use LINQ: var res = (from c in db.Calendars …

-1
228
Member Avatar for ddanbe

I have a `List<double> MyList` something looking like this: 4.75/1.01/5.66/NaN/42.42/3.33 I’d like to get the minimum value of 1.01 out of it, but I get d = NaN when doing `double d = MyList.Min();` Tried, after some long internet strolls, something with LINQ to no avail. Some LINQ afictionados around …

Member Avatar for ddanbe
0
289
Member Avatar for Amr.Mohammad87

Greetings, I am reading about Entity Framework and I stopped by a sentence that I do not understand it *You can simply iterate over the contents of any given DbSet and Entity Framework will send a query to the database to find all the data in that set. The query …

Member Avatar for tinstaafl
0
201
Member Avatar for nlanka

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace Cities { class Hometown { public string City { get; set; } public string State { get; set; } public Hometown(string City, string State ) { this.City = City; this.State = State; } public Hometown() { } …

0
116
Member Avatar for ogsirus

Hi All, I have written a program which contains a class 'Numbers' which can hold a set five numbers. I then create 2 List<Numbers> instances which generate a random numbers. I then loop through one list and try to use linq to find if the list has an identical set …

Member Avatar for ogsirus
0
281
Member Avatar for kukuruku

I do have a dataset with id date code 1 02/02/2012 A 1 02/07/2012 B 1 02/21/2012 A 2 02/02/2012 C 2 02/09/2012 A and I have to create a grid with the days in february and insert the code in the coresponding days id 1 2 3 4 5 …

Member Avatar for tinstaafl
0
155
Member Avatar for game4tress

I'm using linq on a array and I need to find the index of the linq result. Is this possible? how? My thanks in advanced. This is my code: Vector3[] vertices=mesh.vertices; var V3=(from cur in vertices where (cur.x==point.PointX) && (cur.y==point.PointY) select cur).FirstOrDefault();

Member Avatar for ddanbe
0
309
Member Avatar for k030775

Hello, Please forgive me, I am a newbie for programming in C#. I have some experience in VB. I am trying to convert my picture box that I am able to load a picture in, but I would like to convert it to binary then save it to SQL. I …

Member Avatar for k030775
0
231
Member Avatar for Member #1104501

I have searched for a while now and havn't found an answer. Would anyone happen to know how to sort first by letter then number? I have a linq expression which I need to order in this way. Ex. it currently shows up like 01, 02, 03, A1, A2, C1. …

Member Avatar for tinstaafl
0
203
Member Avatar for pritaeas

For a report I had to show a list of items (ID's). Instead of showing them all, they wanted to show consecutive items separated by a dash. Just like the way you would use print pages in Word for example. In the print dialog you can say 1-5, 8 to …

Member Avatar for pritaeas
0
1K
Member Avatar for Member #1104501

var query = (from dt1 in dta.AsEnumerable() join dt2 in dtb.AsEnumerable() on dt1.Field<string>("column1") equals dt2.Field<string>("column1") into outer from Dt2 in outer.DefaultIfEmpty() group new { Dt2 } by new { SearchKey = dt1.Field<string>("SearchKey") } into g select new { Status = g.Select(r => r.Dt2) == null ? string.Empty : g.Select(r => …

Member Avatar for Member #1104501
0
2K
Member Avatar for overwraith

So, I am trying to get a query working that finds a certain flash drive attached to my computer and selects it's DriveInfo object. I am having trouble because on my system when I call the VolumeLabel property of one of my DriveInfo objects it throws an exception (IOException) because …

Member Avatar for overwraith
0
224
Member Avatar for sadaquat_1

I am using asp.net mvc 5 , Entity framework 5, i have following tables: 1. orderid customerid 1 2 2 3 3 1 orderid productname quantity 1 A 10 1 B 15 1 C 20 i.e I want to make a report like following: Total Quantity per customer: total total …

Member Avatar for pritaeas
0
125
Member Avatar for Member #1104501

I am using Linq and keep getting a DBNull error since my datatable contains DBNulls. I have: var Sum = (from dt in dt1.AsEnumerable() where (dtCutOffDate.Subtract(dt.Field<DateTime>("Date")).Days) >= iStartRange && dtCutOffDate.Subtract(dt.Field<DateTime>("Date")).Days <= iEndRange && ((items == null) || (dt.Field<string>("AcctNo") == items)) && (dt.Field<string>("type").Contains("6") || dt.Field<string>("type").Contains("9")) select dt.Field<double>("amount")).Sum(); The date column is …

Member Avatar for Member #1104501
0
2K
Member Avatar for Member #1104501

I'm needing some LINQ expert advice. I am having to convert a SQL stored proceedure over to LINQ. The SQL statement is structured like below: SELECT SUM((Amt) FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.ID WHERE Table1.Date < endDate GROUP BY Table2.Name How would I group all of the …

Member Avatar for AleMonteiro
0
170
Member Avatar for Member #1104501

Hello, I have spent a good long time looking at solutions on the web and can't seem to find any solution to fit my situation. What I'm trying to do is grab 2 specific columns in my datatable with LINQ. Here's a couple things that I have tried: var query …

Member Avatar for Member #1104501
0
1K
Member Avatar for AndrewDBrown

I am pretty new to working with XAML and LINQ and could really do with some help. I need to be able to create and then save new records to my database (bound to objects on my XAML view). I can currently load and existing record, make the changes and …

Member Avatar for Ketsuekiame
0
268
Member Avatar for sumitshah4u

Hi, I have the below datatable created through my C# code: Stock TotalPrice Qty TransactionType XYZ 400 10 BUY ABC 800 20 BUY XYZ 800 20 SELL ABC 400 10 SELL I want this datatable to be processed by LINQ / LAMBDA expressions in such a way that will give …

Member Avatar for Rehan_4
0
219
Member Avatar for ddanbe

Hi, in my polynomial class all the terms consist of a List of tuples (double, uint), representing the coefficient and the exponent; a real and a natural number. The +operator implementation works great, but I was wondering if I could avoid to write two times `grouping.Sum(s => s.Item1)` It somehow …

Member Avatar for ddanbe
0
261
Member Avatar for hussain_ahmed

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.Linq.Mapping; public partial class Default3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public void showgridview() { DataClassesDataContext dc = new DataClassesDataContext(); var q = from a in dc.GetTable<bio>() select a; GridView1.DataSource = q; …

Member Avatar for pritaeas
0
152
Member Avatar for 21345572
Member Avatar for mayaestat
0
124
Member Avatar for 21345572
Member Avatar for ddanbe
0
55
Member Avatar for Fangling

Hi, i have these codes: Dim dt3 As New DataTable dt3.Columns.Add("AdminNo", GetType(String)) '/*Add column AdminNo dt3.Columns.Add("PaperNo", GetType(Integer)) Dim curmodule As String = String.Empty For Each dr1 As DataRow In dt1.Rows curmodule = dr1("ModuleCode").ToString For Each dr2 As DataRow In dt2.Rows Dim found As Boolean found = False For i As …

Member Avatar for Fangling
0
1K
Member Avatar for G_Waddell

Hi All, I'm fairly new to using Linq but I thought I had a handle on it, apparently not though. I'm processing an XML file sent out as an error report by a third party. I have no control over this file and it has been developed to an industry …

Member Avatar for G_Waddell
0
680
Member Avatar for jkvt

Hello, I am trying to create an outer join in Linq using DefaultIfEmpty. It does not seem to be working. Basically I want c.TotalAmount to be 0 if it does not exist in the second/right table. Any ideas as to what I might be doing wrong? The query does execute, …

Member Avatar for jkvt
0
332
Member Avatar for pho.chit.5

I want to know how to set Report viewer from the class of Linq DataContext in class library.

0
64
Member Avatar for jkvt

Hi, I have two LINQ queries that produce two different results, but the fields, while having different names, are essentially the same. I am trying to union them together (although concat in this case should produce the same results), but I am getting an error. My thought is that I …

Member Avatar for jkvt
0
4K
Member Avatar for Kratoswoo

I am using linq for a log in and out type thing. Want to know if there is a way to grab the ID of a row that the persons username is under.... Have 3 tables with 2 primary keys in the 3rd table. Want to save the ID from …

0
133
Member Avatar for SpyrosMet

Hey everyone, so I have this project for windows phone i have to do and I have to put some pins on a bing map, but in order to do that I make an API request to google for google places. I get back an XML file and it's like …

Member Avatar for Ketsuekiame
0
3K
Member Avatar for lulu79

I have a LINQ function to get 3 things :: Line, Average of Duration and Count I have a problem to sort it based on Average Of Duration column. Here is my code: Dim group2 As IEnumerable(Of DataRow) = _ From row In Ds.Tables(0).AsEnumerable() _ Group row By LINENAME = …

Member Avatar for lulu79
0
764
Member Avatar for ddanbe

LINQ is a great extension to the C# language! But it can be terrifying at first. So here is a little snippet just to get your feet wet. You would normally use some sort of looping here. See how easy it is to get some values from an array. Enjoy

Member Avatar for claventure
0
203
Member Avatar for linqtraining

[Click Here](null)To develop database applications in C#, developer must have good understanding of object oriented programming as well as SQL Queries. The goal of this linq tutorial is to make the developer proficient enough to use language integrated query as an alternative to SQL Queries and also to demonstrate how …

0
44
Member Avatar for xixi.li.7

I have a c# linq assignment to add a data from the csv file, here is my code: struct DailyValues { public DateTime Date { get; private set; } public decimal Open { get; private set; } public decimal High { get; private set; } public decimal Low { get; …

Member Avatar for Momerath
0
256
Member Avatar for Acidburn

Hey guys, whats wrong with this? var sublistofsolutions = (from x in p.sol().Where( f => f.ps.Where(a => a.p.Location == location) select x); it keeps saying cannot convert expression type of Ienumerable to bool

0
77
Member Avatar for Begginnerdev

Hello my fellow DaniWebbers, I have a question for you. Problem: I am troubleshooting an ASP.NET (some one else wrote) page that has an insert form. The user can insert, using linq, into the database. I want to check the database for the values before inserting the values. (Safeguarding from …

Member Avatar for Begginnerdev
0
341
Member Avatar for Acidburn

Hey guys, I'm struggling writing some linq. Basically I've got a search method which takes boolean values and decides what results should be included / excluded from the search. Eg Search (bool IncludeStatus1, bool IncludeStatus2, bool includeStatus3...) Now on the back of that I need to create a linq statement …

Member Avatar for Mitja Bonca
0
135
Member Avatar for aldm

Hi, I'm working on one project in .NET 4 and I use LINQ for database access. I have a problem. Consider a following code: Guid userId = new Guid(Membership.GetUser().ProviderUserKey.ToString()); IEnumerable<ViewCount> views = from vc in dbContext.ViewCounts where vc.Time >= dateFrom && vc.Time <= dateTo group vc by new { catalogueId …

Member Avatar for aldm
0
169
Member Avatar for Skeldave

Hi, I am trying to define a 'null' LINQ Table as a global variable and then use a switch statement to deturmine what the Table should be. I am having problems defining the datatype and also assigning values to it. Hopefully the code below will explain better. [CODE] System.Data.Linq.Table table; …

Member Avatar for ddanbe
0
160
Member Avatar for Ggalla1779

Hi guys I need to find next highest no in a field that is a stick ref it has chars at front and 0 padded How so I strip off front chars and 0's to get actual highest no number in the table field? Am using LINQ against entity framework …

Member Avatar for thines01
0
238
Member Avatar for sam1

Hi, Want to remove duplicates from a list so if my list contains: [CODE]www.test.com test.com mytest.com[/CODE] I want the final list to look like below(only selecting the domains with www from the duplicate in front) : [CODE]www.test.com mytest.com [/CODE] I have this linq but it seems to ignore all the …

Member Avatar for sam1
0
249
Member Avatar for dhanlak

Hi, Does anyone know how to sort using linq-entity. i use the following code: from i in objEntities.Items where .... orderby i.Name select i The result is item1,item2,item21, item22, item3. But, i want it to be like item1, item2, item3, item21, item22 Thanks

-1
87
Member Avatar for CSharpUser

First, I want to admit I am totally new at Linq queries. Your help and patience are GREATLY appreciated! I am trying to perform a query on a loaded XML document with the code below, but no matter what I try, I continually get an unhandled NullReferenceException error: [CODE] XDocument …

Member Avatar for CSharpUser
0
479
Member Avatar for jonkeeler

Hi this is my first post so hello everybody, I've recently been exploring the uses of linq to use for comparisons,but really need a bit of a kickstart. Say for instance i have a listview populated with numbered names and I want to put up a message box if certain …

Member Avatar for Member #857553
0
555
Member Avatar for vehpurple

okay so i have Form2 which has a db table named Car using LINQ with four attributes(Make, Model, Year, Price). Now Form1 has 4 textboxs using ReadLines to acquire the make,model,year,price). How do i get them to insert into the table on Form2. thanks in advance for the help.

Member Avatar for vehpurple
0
141
Member Avatar for drax12

hey, i am developing a booking system and i want to check whether user check in dates are within booked dates. for an example. user wants to book 12/03 to 14/03,but some body has already booked 10/03 to 15/03. For this scenario, we just cant check for 2 days,what i …

Member Avatar for zmeditation1
0
116
Member Avatar for Skeldave

Hi, I'm making a tv guide program and I'm letting the user select a start date and an end date and I need to output all the programmes which fall between those times. I'm using linq like this to filter the data [code]var result = from p in programmes where …

Member Avatar for Skeldave
0
129
Member Avatar for ravanan88

how to implement the concept of linq which is goin to retrives all the users(name only) who logged on to system

0
67
Member Avatar for yashodhan05
Member Avatar for Momerath
0
40
Member Avatar for Tazsweet19

I tried to looking for website about ForAll() "Invokes the specified action for each element in the source sequence in paralle from LINQ (PLINQ). There is no example for ForAll(). Let me know thanks.

Member Avatar for Momerath
0
71
Member Avatar for like_bilal02

Dear Freinds I face a problem that if i make a datattype in sql server of Integer and then use it in linq to sql query it give error of "specific cast not valid" and when i change datatype into varchar the linq to sql query work fine one more …

Member Avatar for like_bilal02
0
70

The End.