Search Results

Search found 9232 results on 370 pages for 'linq tutorial'.

Page 16/370 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • How does Linq-to-Xml convert objects to strings?

    - by Eamon Nerbonne
    Linq-to-Xml contains lots of methods that allow you to add arbitrary objects to an xml tree. These objects are converted to strings by some means, but I can't seem to find the specification of how this occurs. The conversion I'm referring to is mentioned (but not specified) in MSDN. I happen to need this for javascript interop, but that doesn't much matter to the question. Linq to Xml isn't just calling .ToString(). Firstly, it'll accept null elements, and secondly, it's doing things no .ToString() implementation does: For example: new XElement("elem",true).ToString() == "<elem>true</elem>" //but... true.ToString() == "True" //IIRC, this is culture invariant, but in any case... true.ToString(CultureInfo.InvariantCulture) == "True" Other basic data types are similarly specially treated. So, does anybody know what it's doing and where that's described?

    Read the article

  • review on django book vs django tutorial

    - by momo
    going through both the django book and tutorial, am a bit confused to the differences in approach (aren't they both written by the same people?) can anyone who has experience in both give a short review on them? i have decent python skills (largely untested though), but no experience at all in web apps and am trying to decide which one to stick to. i briefly looked in to practical django projects but that was a bit too complicated for me, my background is primarily bash scripting, the python i know i learned from an instant hacking tutorial and diving into python.

    Read the article

  • How do I check if a SQL Server 2005 TEXT column is not null or empty using LINQ To Entities?

    - by emzero
    Hi there guys I'm new to LINQ and I'm trying to check whether a TEXT column is null or empty (as String.IsNullOrEmpty). from c in ... ... select new { c.Id, HasBio = !String.IsNullOrEmpty(c.bio) } Trying to use the above query produces an SqlException: Argument data type text is invalid for argument 1 of len function. The SQL generated is similar to the following: CASE WHEN ( NOT (([Extent2].[bio] IS NULL) OR (( CAST(LEN([Extent2].[bio]) AS int)) = 0))) THEN cast(1 as bit) WHEN (([Extent2].[bio] IS NULL) OR (( CAST(LEN([Extent2].[bio]) AS int)) = 0)) THEN cast(0 as bit) END AS [C1] LEN is not applicable to TEXT columns. I know DATALENGTH should be used for them... How can I force LINQ to produce such thing? Or any other workaround to test if a text column is null or empty??? Thanks!

    Read the article

  • Entity Framework VS LINQ to SQL VS ADO.NET with stored procedures?

    - by BritishDeveloper
    How would you rate each of them in terms of: Performance Speed of development Neat, intuitive, maintainable code Flexibility Overall I like my SQL and so have always been a die-hard fan of ADO.NET and stored procedures but I recently had a play with Linq to SQL and was blown away by how quickly I was writing out my DataAccess layer and have decided to spend some time really understanding either Linq to SQL or EF... or neither? I just want to check, that there isn't a great flaw in any of these technologies that would render my research time useless. E.g. performance is terrible, it's cool for simple apps but can only take you so far

    Read the article

  • How to deal with large result sets with Linq to Entities?

    - by user169867
    I have a fairly complex linq to entities query that I display on a website. It uses paging so I never pull down more than 50 records at a time for display. But I also want to give the user the option to export the full results to Excel or some other file format. My concern is that there could potentially be a large # of records all being loaded into memory at one time to do this. Is there a way to process a linq result set 1 record at a time like you could w/ a datareader so only 1 record is really being kept in memory at a time? I'd appreciate any help. Thanks

    Read the article

  • How to use LINQ To Entities for filtering when many methods are not supported?

    - by Kinderchocolate
    Hi, I have a table in SQL database: ID Data Value 1 1 0.1 1 2 0.4 2 10 0.3 2 11 0.2 3 10 0.5 3 11 0.6 For each unique value in Data, I want to filter out the row with the largest ID. For example: In the table above, I want to filter out the third and fourth row because the fifth and sixth rows have the same Data values but their IDs (3) are larger (2 in the third and fourth row). I tried this in Linq to Entities: IQueryable<DerivedRate> test = ObjectContext.DerivedRates.OrderBy(d => d.Data).ThenBy(d => d.ID).SkipWhile((d, index) => (index == size - 1) || (d.ID != ObjectContext.DerivedRates.ElementAt(index + 1).ID)); Basically, I am sorting the list and removing the duplicates by checking if the next element has an identical ID. However, this doesn't work because SkipWhile(index) and ElementAt(index) aren't supported in Linq to Entities. I don't want to pull the entire gigantic table into an array before sorting it. Is there a way?

    Read the article

  • What is the difference between "LINQ to Entities", "LINQ to SQL" and "LINQ to Dataset".

    - by Marcel
    I've been working for quite a while now with LINQ. However, it remains a bit of a mystery what the real differences are between the mentioned flavours of LINQ. The successful answer will contain a short differentiation between them. What is the main goal of each flavor, what is the benefit, and is there a performance impact... P.S. I know that there are a lot of information sources out there, but I'm looking for a kind of a "cheat sheet" which instructs a newbie where to head for a specific goal.

    Read the article

  • What is the differnce between "LINQ to Entities", "LINQ to SQL" and "LINQ to Dataset".

    - by Marcel
    Hi all, I'm working for quite a while now with LINQ. However, it remained still a bit of a mystery what are the real differences between the mentioned flavours of LINQ. The successful answer will contain a short differentiation between them. What is the main goal if it, what is the benefit, and is there a performance impact... P.S. I know that there are a lot of information sources out there, but I look for a kind of a "cheat sheet" which instructs a newbie where to head to for a specific goal.

    Read the article

  • How can I remove an "ALMOST" Duplicate using LINQ? ( OR SQL? )

    - by Atomiton
    This should be and easy one for the LINQ gurus out there. I'm doing a complex Query using UNIONS and CONTAINSTABLE in my database to return ranked results to my application. I'm getting duplicates in my returned data. This is expected. I'm using CONTAINSTABLE and CONTAINS to get all the results I need. CONTAINSTABLE is ranked by SQL and CONTAINS (which is run only on the Keywords field ) is hard-code-ranked by me. ( Sorry if that doesn't make sense ) Anyway, because the tuples aren't identical ( their rank is different ) a duplicate is returned. I figure the best way to deal with this is use LINQ. I know I'll be using the Distinct() extension method, but do I have to implement the IEqualityComparer interface? I'm a little fuzzy on how to do this. For argument's sake, say my resultset is structured like this class: class Content { ContentID int //KEY Rank int Description String } If I have a List<Content> how would I write the Distinct() method to exclude Rank? Ideally I'd like to keep the Content's highest Rank. SO, if one Content's RAnk is 112 and the other is 76. I'd like to keep the 112 rank. Hopefully I've given enough information.

    Read the article

  • What is the return type for a anonymous linq query select? What is the best way to send this data ba

    - by punkouter
    This is a basic question. I have the basic SL4/RIA project set up and I want to create a new method in the domain service and return some data from it. I am unsure the proper easiest way to do this.. Should I wrap it up in a ToList()? I am unclear how to handle this anonymous type that was create.. what is the easiest way to return this data? public IQueryable<ApplicationLog> GetApplicationLogsGrouped() { var x = from c in ObjectContext.ApplicationLogs let dt = c.LogDate group c by new { y = dt.Value.Year, m = dt.Value.Month, d = dt.Value.Day } into mygroup select new { aaa = mygroup.Key, ProductCount = mygroup.Count() }; return x; // return this.ObjectContext.ApplicationLogs.Where(r => r.ApplicationID < 50); } Cannot implicitly convert type 'System.Linq.IQueryable<AnonymousType#1>' to 'System.Linq.IQueryable<CapRep4.Web.ApplicationLog>'. An explicit conversion exists (are you missing a cast?) 58 20 CapRep4.Web

    Read the article

  • LINQ to SQL - Why can't you use a WHERE after an ORDER BY?

    - by MCS
    The following code: // select all orders var orders = from o in FoodOrders where o.STATUS = 1 order by o.ORDER_DATE descending select o; // if customer id is specified, only select orders from specific customer if (customerID!=null) { orders = orders.Where(o => customerID.Equals(o.CUSTOMER_ID)); } gives me the following error: Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IOrderedQueryable'. An explicit conversion exists (are you missing a cast?) I fixed the error by doing the sorting at the end: // select all orders var orders = from o in FoodOrders where o.STATUS = 1 select o; // if customer id is specified, only select orders from specific customer if (customerID!=null) { orders = orders.Where(o => customerID.Equals(o.CUSTOMER_ID)); } // I'm forced to do the ordering here orders = orders.OrderBy(o => o.ORDER_DATE).Reverse(); But I'm wondering why is this limitation in place? What's the reason the API was designed in such a way that you can't add a where constraint after using an order by operator?

    Read the article

  • LINQ to Entities question about orderby and null collections.

    - by Chevex
    I am currently developing a forum. I am new to LINQ and EF. In my forum I have a display that shows a list of topics with the most recent topics first. The problem is that "most recent" is relative to the topic's replies. So I don't want to order the list by the topic's posted date, rather I want to order the list by the topic's last reply's posted date. So that topics with newer replies pop back to the top of the list. This is rather simple if I knew that every topic had at least one reply; I would just do this: var topicsQuery = from x in board.Topics orderby x.Replies.Last().PostedDate descending select x; However, in many cases the topic has no replies. In which case I would like to use the topic's posted date instead. Is there a way within my linq query to order by x.PostedDate in the event that the topic has no replies? I'm getting confused by this and any help would be appreciated. With the above query, it breaks on topics with no replies because of the x.Replies.Last() which assumes there are replies. LastOrDefault() doesn't work because I need to access the PostedDate property which also assumes a reply exists. Thanks in advance for any insight.

    Read the article

  • How to add second JOIN clause in Linq To Sql?

    - by Refracted Paladin
    I am having a lot of trouble coming up with the Linq equivalent of this legacy stored procedure. The biggest hurdle is it doesn't seem to want to let me add a second 'clause' on the join with tblAddress. I am getting a Cannot resolve method... error. Can anyone point out what I am doing wrong? Below is, first, the SPROC I need to convert and, second, my LINQ attempt so far; which is FULL OF FAIL! Thanks SELECT dbo.tblPersonInsuranceCoverage.PersonInsuranceCoverageID, dbo.tblPersonInsuranceCoverage.EffectiveDate, dbo.tblPersonInsuranceCoverage.ExpirationDate, dbo.tblPersonInsuranceCoverage.Priority, dbo.tblAdminInsuranceCompanyType.TypeName AS CoverageCategory, dbo.tblBusiness.BusinessName, dbo.tblAdminInsuranceType.TypeName AS TypeName, CASE WHEN dbo.tblAddress.AddressLine1 IS NULL THEN '' ELSE dbo.tblAddress.AddressLine1 END + ' ' + CASE WHEN dbo.tblAddress.CityName IS NULL THEN '' ELSE '<BR>' + dbo.tblAddress.CityName END + ' ' + CASE WHEN dbo.tblAddress.StateID IS NULL THEN '' WHEN dbo.tblAddress.StateID = 'ns' THEN '' ELSE dbo.tblAddress.StateID END AS Address FROM dbo.tblPersonInsuranceCoverage LEFT OUTER JOIN dbo.tblInsuranceCompany ON dbo.tblPersonInsuranceCoverage.InsuranceCompanyID = dbo.tblInsuranceCompany.InsuranceCompanyID LEFT OUTER JOIN dbo.tblBusiness ON dbo.tblBusiness.BusinessID = dbo.tblInsuranceCompany.BusinessID LEFT OUTER JOIN dbo.tblAddress ON dbo.tblAddress.BusinessID = dbo.tblBusiness.BusinessID and tblAddress.AddressTypeID = 'b' LEFT OUTER JOIN dbo.tblAdminInsuranceCompanyType ON dbo.tblPersonInsuranceCoverage.InsuranceCompanyTypeID = dbo.tblAdminInsuranceCompanyType.InsuranceCompanyTypeID LEFT OUTER JOIN dbo.tblAdminInsuranceType ON dbo.tblPersonInsuranceCoverage.InsuranceTypeID = dbo.tblAdminInsuranceType.InsuranceTypeID WHERE tblPersonInsuranceCoverage.PersonID = @PersonID var coverage = from insuranceCoverage in context.tblPersonInsuranceCoverages where insuranceCoverage.PersonID == personID join insuranceCompany in context.tblInsuranceCompanies on insuranceCoverage.InsuranceCompanyID equals insuranceCompany.InsuranceCompanyID join address in context.tblAddresses on insuranceCompany.tblBusiness.BusinessID equals address.BusinessID where address.AddressTypeID = 'b' select new { insuranceCoverage.PersonInsuranceCoverageID, insuranceCoverage.EffectiveDate, insuranceCoverage.ExpirationDate, insuranceCoverage.Priority, CoverageCategory = insuranceCompany.tblAdminInsuranceCompanyType.TypeName, insuranceCompany.tblBusiness.BusinessName, TypeName = insuranceCoverage.InsuranceTypeID, Address = };

    Read the article

  • How can I use a compound condition in a join in Linq?

    - by Gary McGill
    Let's say I have a Customer table which has a PrimaryContactId field and a SecondaryContactId field. Both of these are foreign keys that reference the Contact table. For any given customer, either one or two contacts may be stored. In other words, PrimaryContactId can never be NULL, but SecondaryContactId can be NULL. If I drop my Customer and Contact tables onto the "Linq to SQL Classes" design surface, the class builder will spot the two FK relationships from the Customer table to the Contact table, and so the generated Customer class will have a Contact field and a Contact1 field (which I can rename to PrimaryContact and SecondaryContact to avoid confusion). Now suppose that I want to get details of all the contacts for a given set of customers. If there was always exactly one contact then I could write something like: from customer in customers join contact in contacts on customer.PrimaryContactId equals contact.id select ... ...which would be translated into something like: SELECT ... FROM Customer INNER JOIN Contact ON Customer.FirstSalesPersonId = Contact.id But, because I want to join on both the contact fields, I want the SQL to look something like: SELECT ... FROM Customer INNER JOIN Contact ON Customer.FirstSalesPersonId = Contact.id OR Customer.SecondSalesPersonId = Contact.id How can I write a Linq expression to do that?

    Read the article

  • How do I add a where filter using the original Linq-to-SQL object in the following scenario

    - by GenericTypeTea
    I am performing a select query using the following Linq expression: Table<Tbl_Movement> movements = context.Tbl_Movement; var query = from m in movements select new MovementSummary { Id = m.DocketId, Created = m.DateTimeStamp, CreatedBy = m.Tbl_User.FullName, DocketNumber = m.DocketNumber, DocketTypeDescription = m.Ref_DocketType.DocketType, DocketTypeId = m.DocketTypeId, Site = new Site() { Id = m.Tbl_Site.SiteId, FirstLine = m.Tbl_Site.FirstLine, Postcode = m.Tbl_Site.Postcode, SiteName = m.Tbl_Site.SiteName, TownCity = m.Tbl_Site.TownCity, Brewery = new Brewery() { Id = m.Tbl_Site.Ref_Brewery.BreweryId, BreweryName = m.Tbl_Site.Ref_Brewery.BreweryName }, Region = new Region() { Description = m.Tbl_Site.Ref_Region.Description, Id = m.Tbl_Site.Ref_Region.RegionId } } }; I am also passing in an IFilter class into the method where this select is performed. public interface IJobFilter { int? PersonId { get; set; } int? RegionId { get; set; } int? SiteId { get; set; } int? AssetId { get; set; } } How do I add these where parameters into my SQL expression? Preferably I'd like this done in another method as the filtering will be re-used across multiple repositories. Unfortunately when I do query.Where it has become an IQueryable<MovementSummary>. I'm assuming it has become this as I'm returning an IEnumerable<MovementSummary>. I've only just started learning LINQ, so be gentle.

    Read the article

  • Why are my bound parameters all identical (using Linq)?

    - by Scott Stafford
    When I run this snippet of code: string[] words = new string[] { "foo", "bar" }; var results = from row in Assets select row; foreach (string word in words) { results = results.Where(row => row.Name.Contains(word)); } I get this SQL: -- Region Parameters DECLARE @p0 VarChar(5) = '%bar%' DECLARE @p1 VarChar(5) = '%bar%' -- EndRegion SELECT ... FROM [Assets] AS [t0] WHERE ([t0].[Name] LIKE @p0) AND ([t0].[Name] LIKE @p1) Note that @p0 and @p1 are both bar, when I wanted them to be foo and bar. I guess Linq is somehow binding a reference to the variable word rather than a reference to the string currently referenced by word? What is the best way to avoid this problem? (Also, if you have any suggestions for a better title for this question, please put it in the comments.) Note that I tried this with regular Linq also, with the same results (you can paste this right into Linqpad): string[] words = new string[] { "f", "a" }; string[] dictionary = new string[] { "foo", "bar", "jack", "splat" }; var results = from row in dictionary select row; foreach (string word in words) { results = results.Where(row => row.Contains(word)); } results.Dump(); Dumps: bar jack splat

    Read the article

  • Reading XML element & child nodes using LINQ in Vb.net- help me in where condition :(

    - by New Linq Baby
    Hi, I am new in LINQ world. I need an urgent help in reading the xml elements using LINQ with specific where condition. I need to find the max air_temp for a county i.e where county name = "Boone" and hour id = "06/03/2009 09:00CDT" i tried something like below, but no luck : Dim custs As IEnumerable = From c In Element.Load("C:\meridian.xml").Elements("county") _ Select c.Elements("hour").Elements("air_temp").Max() For Each x In custs Response.Write(custs(0).ToString()) Next ------------------- here is the xml file : <forecasts> <issued>06/02/2009 12:00CDT</issued> - <county name="Adair"> - <hour id="06/02/2009 12:00CDT"> <air_temp>61</air_temp> <cloud_cover>overcast</cloud_cover> <dew_point>59</dew_point> <precip_prob>90</precip_prob> <precip_rate>0.12</precip_rate> <precip_type>rain</precip_type> <snow_rate>0.0</snow_rate> <wind_direction>NE</wind_direction> <wind_speed>12</wind_speed> <dew_point_confidence>-3/+3</dew_point_confidence> <road_temp>64</road_temp> <road_frost_prob>0</road_frost_prob> <road_potential_evap_rate>429</road_potential_evap_rate> <road_temp_confidence>-3/+2</road_temp_confidence> <dew_point_confidence>-3/+3</dew_point_confidence> <bridge_temp>63</bridge_temp> <bridge_temp_confidence>-4/+2</bridge_temp_confidence> <bridge_frost>NO</bridge_frost> </hour> - <hour id="06/02/2009 13:00CDT"> <air_temp>61</air_temp> <cloud_cover>overcast</cloud_cover> <dew_point>60</dew_point> <precip_prob>70</precip_prob> <precip_rate>0.01</precip_rate> <precip_type>rain</precip_type> <snow_rate>0.0</snow_rate> <wind_direction>ENE</wind_direction> <wind_speed>10</wind_speed> <dew_point_confidence>-3/+3</dew_point_confidence> <road_temp>65</road_temp> <road_frost_prob>0</road_frost_prob> <road_potential_evap_rate>411</road_potential_evap_rate> <road_temp_confidence>-3/+2</road_temp_confidence> <dew_point_confidence>-3/+3</dew_point_confidence> <bridge_temp>64</bridge_temp> <bridge_temp_confidence>-4/+1</bridge_temp_confidence> <bridge_frost>NO</bridge_frost> </hour>

    Read the article

  • SlickGrid and asp.net sample or tutorial

    - by user322862
    Hi, I am a newbie using SlickGrid. I have searched some of the sample apps out there but I am still stumped. If anyone can refer a sample or tutorial on SlickGrid using Asp.Net doing the following: Get data via JSON Implement paging, sorting, searching Pass the selected rows key to code behind for processing or call a codebehind function passing the selected rows key. Any help would be appreciated. TIA, TE:-D

    Read the article

  • LINQ to SQL - Save an entity without creating a new DataContext?

    - by aximili
    I get this error Cannot add an entity with a key that is already in use when I try to save an Item [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(Item item) { Global.DataContext.Items.Attach(item); Global.DataContext.SubmitChanges(); return View(item); } That's because I cannot attach the item to the static global DataContext. Is it possible to save an item without creating a new DataContext? (I am very new to LINQ)

    Read the article

  • Maven Tutorial that Covers a Complete Project Lifecycle

    - by Jonas Laufu
    Can anyone point to a maven tutorial / how-to that covers everything that is normally required during an OSS project: project creation, sources, build, test, integration in SCM, etc, deployment to one's own repository, release creation and upload? I have been able to gather all this information from ten different sources, but it is not easy to get the complete picture because every source expects a different state of existing knowledge.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >