Search Results

Search found 7676 results on 308 pages for 'linq extensions'.

Page 44/308 | < Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >

  • ordering by a property on a joined table linq to sql

    - by Gazeth
    I have the following linq query from o in context.Opportunities join i in context.Interactions on o.OpportunityID equals i.OpportunityID into ints from i in ints.DefaultIfEmpty() orderby i.StatusID descending, o.StatusID descending select o Now i want to then do a distinct on the opportunities table but doing so removes my orderby. I know that you can do Distinct().OrderBy but how do i get a reference to the interactions table that was joined when I'm only selecting the opportunity entity?

    Read the article

  • Need help Linq query join + count + group by

    - by user233540
    I have two table First table BID Town 1 ABC 2 ABC2 3 ABC Second Table PID BID AmountFirst AmountSecond AmountThird Minority 1__ 1___ 1000_____ 1000________ 1000_____ SC 2__ 2___ 2000_____ 1000_______ 2000_____ ST 3__ 3___ 1000____ 1000_______ 1000_______ SC BID is foreign key in Second table. I want sum AmountFirst + AmountSecond +AmountThird for individualTown e.g for ABC town answer should be : 6000 (summation of PID 1 and PID 2) I want Linq query for this..Please help

    Read the article

  • Many to many in linq with vb.net

    - by user512623
    I have 3 tables in a database: image of the database I have been looking online for a long time trying to find out how in linq and vb.net how i can do a query that has access to both the event and individual table for example showing all the events individual 1 is taking part in ect. i was wondering if anyone could point me in the right direction or know of any good tutorial sites with good examples of things similar. Thanks in advance :) Luke.

    Read the article

  • Access different columns from LINQ resultset

    - by Piyush
    I have a query which returns multiple columns from the database using LINQ var donors = from d2 in db.Donors where d2.Status == "Pending" select new { donorID = d2.donorID, bloodGroup = d2.bloodGroup, contactNo = d2.contactMobile, status = d2.Status }; now I want to display the results in different Labels accessing one column value from donors resultset. ex: Label1.Text = donorID; Label2.Text = bloodGroup; ...and so on please help me achieve this.

    Read the article

  • left join on linq

    - by ognjenb
    SQL: FROM `order` o LEFT JOIN person d ON o.`DistributorId` = d.`Id` LEFT JOIN person c ON o.`CustomerId` = c.Id LEFT JOIN Transporter t ON o.`TransporterId` = t.Id LEFT JOIN IbekoEngineer e ON o.OrderEnteredBy = e.Id In any way to translate this 4 left join to LINQ query

    Read the article

  • LINQ display row numbers

    - by timvaines
    I simply want to include a row number against the returned results of my query. I found the following post that describes what I am trying to achieve but gives me an exception http://vaultofthoughts.net/LINQRowNumberColumn.aspx "An expression tree may not contain an assignment operator" In MS SQL I would just use the ROWNUMBER() function, I'm simply looking for the equivalent in LINQ.

    Read the article

  • Linq to entity select items and give id

    - by GodSmart
    I have a table example you can see below ID Name Value 3 NameOne ValueOne 7 NameTwo ValueTwo 10 NameThree ValueThree I need to select with Linq to Entity and get results as you can see in example below: ItemID ItemName 1 NameOne 2 NameTwo 3 NameThree

    Read the article

  • linq group by with count

    - by snorlaks
    Hello, Im trying to write query in linq Select UserId, UserNumber FROM User where UserNumber in (Select UserNumber FROM User group by UserNumber having Count(UserId) = 1) Aby hints ?

    Read the article

  • Check Directories in C# using Linq

    - by pm_2
    Can someone tell me what I'm doing wrong with the following Linq query? I'm trying to find the directory with the highest aphanumerical value. DirectoryInfo[] diList = currentDirectory.GetDirectories(); var dirs = from eachDir in diList orderby eachDir.FullName descending select eachDir; MessageBox.Show(dirs[0].FullName);

    Read the article

  • Get groups of 4 elements from name value list using LINQ in C#

    - by Kodefoo
    I am wanting to loop through this list of name value pairs and grab them in groups of 4. The data would be like: value1 1 value2 1 value3 1 value4 1 value1 2 value2 2 value3 2 value4 2 and it would group it as 1 list that contains value1 1 value2 1 value3 1 value4 1 and another list that contains value1 2 value2 2 value3 2 value4 2 I know this can be done easily with a for loop, but I am wondering if there is a good way to do it with LINQ.

    Read the article

  • Entity Framework: How to bind related products

    - by Waheed
    I am using the following Linq query from p in Product.Include("ProductDetails.Colors") where p.ProductID.Equals(18) select p; And then using the result of this query to bind the GridView. The productDetails are bind to the grid fine, but the Colors are not bind. To bind colors i am using <%# Eval("Colors.CategoryName") %. Error is " Field or property with the name 'Colors.CategoryName' was not found on the selected data source." But in a loop i am getting this fine. foreach (ProductDetails proDet in pd.ProductDetails) { string bar = proDet.BarCode; string color = proDet.Colors.CategoryName; }

    Read the article

  • grouping data from two dataset

    - by Garcia Julien
    hi, i've got a problem with dataset: I've got two dataset from two different server but they have the same columns. so it's like that: First DataSet : asset description make jobtype jan feb ... dec 0001 mine ik Acc 0 0 10 0002 yours ic Over 0 0 10 Second dataset : asset description make jobtype jan feb ... dec 0001 mine ik Acc 10 0 10 0002 yours ic Gen 0 0 0 But i would like to merge the 2 dataset into one like that: asset description make jobtype lhjan imjan lhfeb lhfeb ... lhdec imdec 0001 mine ik Acc 0 10 0 0 10 10 0002 yours ic Over 0 0 0 0 10 0 so all the data from one is combine with the second with the same asset and the same jobtype. I try linq but i can't arrive to make it like i want. I'm working on vb.net framework 3.5. could you help me? Julien

    Read the article

  • 2 listbox to exchange value with DBML

    - by Garcia Julien
    Hi, i'have two Listbox. the think is i do the transfert like : click on field in the left listbox, hit "move right" button and it wll display in the right list box.' The other think it's the first Listbox is bind on Dataset and the second on Entity (Linq-to sql). So when i click on the move next i do that : Dim newSite As New List(Of vw_SiteList) For Each row As SitesDataset.FDDSTRow In SiteAdsListBox.SelectedItems newSite.Add(New vw_SiteList With { _ .SITECODE = row.DEST_COD, _ .SiteDisplay = row.SiteDisplay, _ .CREATEDBY = Environment.GetEnvironmentVariable("USERNAM"), _ .DATECREATED = Now _ }) Next JCDataContext.vw_SiteLists.InsertAllOnSubmit(NewSite) I would like to see now the new field in the right listbox but it isn't there because the field itr's not yet added in the database. How can i do that? Thanks Ju

    Read the article

  • How to include associative table information and still retain strong typing

    - by mwright
    I am using LINQ to SQL to create strongly typed objects in my project. Let's say I have an object that is represented by a database table. This object has a "Current State" that is kept in an associative table. I would like to make a single db call where I pull back the two tables joined but am unsure how I should be populating that information into some sort of object to preserve strong typing within my model so that the view using the information can just consume the information from the objects. I looked into creating a view model for this but it doesn't seem to quite fit. Am I thinking about this in the wrong way? What information can I include to help clarify my problem? Other details that may or may not be important: It's an MVC project....

    Read the article

  • Compiled Queries and "Parameters cannot be sequences"

    - by David B
    I thought that compiled queries would perform the same query translation as DataContext. Yet I'm getting a run-time error when I try to use a query with a .Contains method call. Where have I gone wrong? //private member which holds a compiled query. Func<DataAccess.DataClasses1DataContext, List<int>, List<DataAccess.TestRecord>> compiledFiftyRecordQuery = System.Data.Linq.CompiledQuery.Compile <DataAccess.DataClasses1DataContext, List<int>, List<DataAccess.TestRecord>> ((dc, ids) => dc.TestRecords.Where(tr => ids.Contains(tr.ID)).ToList()); //this method calls the compiled query. public void FiftyRecordCompiledQueryByID() { List<int> IDs = GetRandomInts(50); //System.NotSupportedException //{"Parameters cannot be sequences."} List<DataAccess.TestRecord> results = compiledFiftyRecordQuery (myContext, IDs); }

    Read the article

  • Automatically generate buddy classes from model in C#

    - by JohnnyO
    I use Linq to Sql (although this is equally applicable in Entity Framework) for my models, and I'm finding myself creating buddy classes for my models all the time. I find this time consuming and repetitive. Is there an easy way to automatically generate these buddy classes based on the models? Perhaps a visual studio macro? An example of a buddy class that I'd like to create: [MetadataType(typeof(PersonMetadata))] public partial class Person { } public class PersonMetadata { public object Id { get; set; } public object FirstName { get; set; } } Thanks in advance.

    Read the article

  • Can't get results from a IQueryable.

    - by StackPointer
    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(); IEnumerable<Entity> entities= from ent in p.Entity Where ent.EntityType.DESCRIPTION=="SomeEntityType" select ent; Console.Writeline(entities.ElementAt(0).NAME); } It says, "Object not set to an instance", but if I do: foreach(Policy p in policy){ if(!p.Entity.IsLoaded) p.Entity.Load(); foreach(Entity et in p.Entity)Console.Write(et.NAME); } It works! Can anyone tell me why? Thank you, Best regards.

    Read the article

  • LINQ2SQL: orderby note.hasChildren(), name ascending

    - by Peter Bridger
    I have a hierarchical data structure which I'm displaying in a webpage as a treeview. I want to data to be ordered to first show nodes ordered alphabetically which have no children, then under these nodes ordered alphabetically which have children. Currently I'm ordering all nodes in one group, which means nodes with children appear next to nodes with no children. I'm using a recursive method to build up the treeview, which has this LINQ code at it's heart: var filteredCategory = from c in category orderby c.Name ascending where c.ParentCategoryId == parentCategoryId && c.Active == true select c; So this is the orderby statement I want to enhance. Shown below is the database table structure: [dbo].[Category]( [CategoryId] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](100) NOT NULL, [Level] [tinyint] NOT NULL, [ParentCategoryId] [int] NOT NULL, [Selectable] [bit] NOT NULL CONSTRAINT [DF_Category_Selectable] DEFAULT ((1)), [Active] [bit] NOT NULL CONSTRAINT [DF_Category_Active] DEFAULT ((1))

    Read the article

< Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >