Search Results

Search found 6252 results on 251 pages for 'linq expressions'.

Page 18/251 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • 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

  • 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 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

  • 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

  • How to detect if a LINQ enumeration is materialized?

    - by Peter Lillevold
    Is there some way of detecting whether an enumerable built using LINQ (to Objects in this case) have been materialized or not? Other than trying to inspect the type of the underlying collection? Specifically, since enumerable.ToArray() will build a new array even if the underlying collection already is an array I'm looking for a way of avoiding ToArray() being called twice on the same collection.

    Read the article

  • How to use Linq to select and group complex child object from a parents list.

    - by Daoming Yang
    How to use Linq to select and group complex child object from a parents list. I have an OrderList each of order object has a OrderProductVariantList(OrderLineList), and each of OrderProductVariant object has ProductVariant, and then the ProductVariant object will have a Product object which contains product information. My goal is to select and group the most popular products from the order list. Can anyone help me with this? Many thanks.

    Read the article

  • How to map LINQ EntitySet to List property in property setter?

    - by jlp
    In my model I have these entities: public interface IOrder { string Name {get;set;} List<IProduct> OrderedProducts {get;set;} } public interface IProduct {} In partial class generated by linq-to-sql I map these properties on my entity properties: public partial class Order : IOrder { List<IProduct> OrderedProducts { get { return this.L2SQLProducts.Cast<IProduct>.ToList(); } set { this.L2SQLProducts = ??? } } } How should setter look like?

    Read the article

  • How can I do a multi level parent-child sort using Linq?

    - by Tenacious T
    How can I do a multi-level parent-child sort using Linq if I have a table structure like the one below: [Table: Sections] Id Seq Name ParentSectionId 1 1 TOP NULL 2 1 AAAA 1 3 2 SSSS 1 4 3 DDDD 1 5 1 SectionA1 2 6 2 SectionA2 2 7 1 SectionS1 3 8 3 ASummary 2 Expected sort result: TOP AAAA SectionA1 SectionA2 ASummary SSSS SectionS1 DDDD

    Read the article

  • C# and F# lambda expressions code generation

    - by ControlFlow
    Let's look at the code, generated by F# for simple function: let map_add valueToAdd xs = xs |> Seq.map (fun x -> x + valueToAdd) The generated code for lambda expression (instance of F# functional value) will looks like this: [Serializable] internal class map_add@3 : FSharpFunc<int, int> { public int valueToAdd; internal map_add@3(int valueToAdd) { this.valueToAdd = valueToAdd; } public override int Invoke(int x) { return (x + this.valueToAdd); } } And look at nearly the same C# code: using System.Collections.Generic; using System.Linq; static class Program { static IEnumerable<int> SelectAdd(IEnumerable<int> source, int valueToAdd) { return source.Select(x => x + valueToAdd); } } And the generated code for the C# lambda expression: [CompilerGenerated] private sealed class <>c__DisplayClass1 { public int valueToAdd; public int <SelectAdd>b__0(int x) { return (x + this.valueToAdd); } } So I have some questions: Why does F#-generated class is not marked as sealed? Why does F#-generated class contains public fields since F# doesn't allows mutable closures? Why does F# generated class has the constructor? It may be perfectly initialized with the public fields... Why does C#-generated class is not marked as [Serializable]? Also classes generated for F# sequence expressions are also became [Serializable] and classes for C# iterators are not.

    Read the article

  • Lambda Expressions and Stored Procedures

    - by Jason Summers
    Hi Everyone. I'm trying to mimic the LINQ Where extension method for my ADO.NET DAL methods. Bascially, my aim is to have a single method that I can call. Such as: Product p = Dal.GetProduct(x => x.ProductId == 32); Product p2 = Dal.GetProduct(x => x.ProductName.Contains("Soap")); I then want to dissect those Predicates and send the filter options to parameters in an ADO.NET Stored Procedure call. Any comments greatly appreciated.

    Read the article

  • nhibernate activerecord linq Contains problem

    - by Robert Ivanc
    Hi, I am having problems with the following query in Castle ActiveRecord 2.12: var q = from o in SodisceFMClientVAR.Queryable where taxnos2.Contains(o.TaxFileNo) select o; taxNos2 is an array of strings. When run I get an exception: + InnerException {"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"} System.Exception {System.ArgumentOutOfRangeException} StackTrace " at Castle.ActiveRecord.ActiveRecordBase.ExecuteQuery(IActiveRecordQuery query)\r\n at Castle.ActiveRecord.Linq.LinqResultWrapper`1.Populate()\r\n at Castle.ActiveRecord.Linq.LinqResultWrapper`1.GetEnumerator()\r\n at NHibernate.Linq.Query`1.GetEnumerator()\r\n at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\r\n at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n at prosoft.skb.insolventnostDataAccess.InsolventnostDataAccAR.GetOurUsersListLS(ICollection`1 taxNos) in C:\\svn\\skb\\insolventnostWithAR\\prosoft.skb.insolventnostDataAccess\\InsolventnostDataAR.cs:line 214\r\n at prosoft.skb.insolventnostDataFromWS.InsolventnostFromWS.filterByOurUsers(IEnumerable`1 odprtiPostopki) in C:\\svn\\skb\\insolventnostWithAR\\prosoft.skb.insolventnostDataFromWS\\InsolventnostFromWS.cs:line 237\r\n at prosoft.skb.insolventnostDataFromWS.InsolventnostFromWS.SyncData() in C:\\svn\\skb\\insolventnostWithAR\\prosoft.skb.insolventnostDataFromWS\\InsolventnostFromWS.cs:line 53" string Does Contains even work in linq for nhibernate? I couldn't find anything via google... Is there a workaround? Thanks!

    Read the article

  • LINQ Queries And Context

    - by Soo
    Hello SO, I have a slight issue with some code I'm writing if(parameter == 1) { var linq = from a in db.table select a; } else { var linq = from a in db.table where a.id = 1 select a; } foreach(var b in linq) { ... } So basically what's going on is that the variable "linq" is different depending on the value of "parameter". When I try to loop through "linq" with my foreach loop, I get an error about how linq doesn't exist in the current context. What is the best way to work around this type of issue?

    Read the article

  • Does LINQ require significantly more processing cycles and memory than lower-level data iteration techniques?

    - by Matthew Patrick Cashatt
    Background I am recently in the process of enduring grueling tech interviews for positions that use the .NET stack, some of which include silly questions like this one, and some questions that are more valid. I recently came across an issue that may be valid but I want to check with the community here to be sure. When asked by an interviewer how I would count the frequency of words in a text document and rank the results, I answered that I would Use a stream object put the text file in memory as a string. Split the string into an array on spaces while ignoring punctuation. Use LINQ against the array to .GroupBy() and .Count(), then OrderBy() said count. I got this answer wrong for two reasons: Streaming an entire text file into memory could be disasterous. What if it was an entire encyclopedia? Instead I should stream one block at a time and begin building a hash table. LINQ is too expensive and requires too many processing cycles. I should have built a hash table instead and, for each iteration, only added a word to the hash table if it didn't otherwise exist and then increment it's count. The first reason seems, well, reasonable. But the second gives me more pause. I thought that one of the selling points of LINQ is that it simply abstracts away lower-level operations like hash tables but that, under the veil, it is still the same implementation. Question Aside from a few additional processing cycles to call any abstracted methods, does LINQ require significantly more processing cycles to accomplish a given data iteration task than a lower-level task (such as building a hash table) would?

    Read the article

  • LINQ 4 XML - What is the proper way to query deep in the tree structure?

    - by Keith Barrows
    I have an XML structure that is 4 deep: <?xml version="1.0" encoding="utf-8"?> <EmailRuleList xmlns:xsd="EmailRules.xsd"> <TargetPST name="Tech Communities"> <Parse emailAsList="true" useJustDomain="false" fromAddress="false" toAddress="true"> <EmailRule address="@aspadvice.com" folder="Lists, ASP" saveAttachments="false" /> <EmailRule address="@sqladvice.com" folder="Lists, SQL" saveAttachments="false" /> <EmailRule address="@xmladvice.com" folder="Lists, XML" saveAttachments="false" /> </Parse> <Parse emailAsList="false" useJustDomain="false" fromAddress="false" toAddress="true"> <EmailRule address="[email protected]" folder="Special Interest Groups|Northern Colorado Architects Group" saveAttachments="false" /> <EmailRule address="[email protected]" folder="Support|SpamBayes" saveAttachments="false" /> </Parse> <Parse emailAsList="false" useJustDomain="false" fromAddress="true" toAddress="false"> <EmailRule address="[email protected]" folder="Support|GoDaddy" saveAttachments="false" /> <EmailRule address="[email protected]" folder="Support|No-IP.com" saveAttachments="false" /> <EmailRule address="[email protected]" folder="Discussions|Orchard Project" saveAttachments="false" /> </Parse> <Parse emailAsList="false" useJustDomain="true" fromAddress="true" toAddress="false"> <EmailRule address="@agilejournal.com" folder="Newsletters|Agile Journal" saveAttachments="false"/> <EmailRule address="@axosoft.ccsend.com" folder="Newsletters|Axosoft Newsletter" saveAttachments="false"/> <EmailRule address="@axosoft.com" folder="Newsletters|Axosoft Newsletter" saveAttachments="false"/> <EmailRule address="@cmcrossroads.com" folder="Newsletters|CM Crossroads" saveAttachments="false" /> <EmailRule address="@urbancode.com" folder="Newsletters|Urbancode" saveAttachments="false" /> <EmailRule address="@urbancode.ccsend.com" folder="Newsletters|Urbancode" saveAttachments="false" /> <EmailRule address="@Infragistics.com" folder="Newsletters|Infragistics" saveAttachments="false" /> <EmailRule address="@zdnet.online.com" folder="Newsletters|ZDNet Tech Update Today" saveAttachments="false" /> <EmailRule address="@sqlservercentral.com" folder="Newsletters|SQLServerCentral.com" saveAttachments="false" /> <EmailRule address="@simple-talk.com" folder="Newsletters|Simple-Talk Newsletter" saveAttachments="false" /> </Parse> </TargetPST> <TargetPST name="[Sharpen the Saw]"> <Parse emailAsList="false" useJustDomain="false" fromAddress="false" toAddress="true"> <EmailRule address="[email protected]" folder="Head Geek|Job Alerts" saveAttachments="false" /> <EmailRule address="[email protected]" folder="Social|LinkedIn USMC" saveAttachments="false"/> </Parse> <Parse emailAsList="false" useJustDomain="false" fromAddress="true" toAddress="false"> <EmailRule address="[email protected]" folder="Head Geek|Job Alerts" saveAttachments="false" /> <EmailRule address="[email protected]" folder="Head Geek|Job Alerts" saveAttachments="false" /> <EmailRule address="[email protected]" folder="Social|Cruise Critic" saveAttachments="false"/> </Parse> <Parse emailAsList="false" useJustDomain="true" fromAddress="true" toAddress="false"> <EmailRule address="@moody.edu" folder="Social|5 Love Languages" saveAttachments="false" /> <EmailRule address="@postmaster.twitter.com" folder="Social|Twitter" saveAttachments="false"/> <EmailRule address="@diabetes.org" folder="Physical|American Diabetes Association" saveAttachments="false"/> <EmailRule address="@membership.webshots.com" folder="Social|Webshots" saveAttachments="false"/> </Parse> </TargetPST> </EmailRuleList> Now, I have both an FromAddress and a ToAddress that is parsed from an incoming email. I would like to do a LINQ query against a class set that was deserialized from this XML. For instance: ToAddress = [email protected] FromAddress = [email protected] Query: Get EmailRule.Include(Parse).Include(TargetPST) where address == ToAddress AND Parse.ToAddress==true AND Parse.useJustDomain==false Get EmailRule.Include(Parse).Include(TargetPST) where address == [ToAddress Domain Only] AND Parse.ToAddress==true AND Parse.useJustDomain==true Get EmailRule.Include(Parse).Include(TargetPST) where address == FromAddress AND Parse.FromAddress==true AND Parse.useJustDomain==false Get EmailRule.Include(Parse).Include(TargetPST) where address == [FromAddress Domain Only] AND Parse.FromAddress==true AND Parse.useJustDomain==true I am having a hard time figuring this LINQ query out. I can, of course, loop on all the bits in the XML like so (includes deserialization into objects): XmlSerializer s = new XmlSerializer(typeof(EmailRuleList)); TextReader r = new StreamReader(path); _emailRuleList = (EmailRuleList)s.Deserialize(r); TargetPST[] PSTList = _emailRuleList.Items; foreach (TargetPST targetPST in PSTList) { olRoot = GetRootFolder(targetPST.name); if (olRoot != null) { Parse[] ParseList = targetPST.Items; foreach (Parse parseRules in ParseList) { EmailRule[] EmailRuleList = parseRules.Items; foreach (EmailRule targetFolders in EmailRuleList) { } } } } However, this means going through all these loops for each and every address. It makes more sense to me to query against the Objects. Any tips appreciated!

    Read the article

  • linq query - The method or operation is not implemented.

    - by Dejan.S
    I'm doing the Rob Conery mvc storefront and at one place I'm suppose to get categories but I get an error with this linq query and I can not get why. It's exactly the same as his. var culturedName = from ct in ReadOnlyContext.CategoryCultureDetails where ct.Culture.LanguageCode == System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName select new { ct.CategoryName, ct.CategoryId }; return from c in ReadOnlyContext.Categories join cn in culturedName on c.CategoryId equals cn.CategoryId select new Core.Model.Category { Id = c.CategoryId, Name = cn.CategoryName, ParentId = c.ParentId ?? 0, Products = new LazyList<Core.Model.Product>(from p in GetProducts() join cp in ReadOnlyContext.Categories_Products on p.Id equals cp.ProductId where cp.CategoryId == c.CategoryId select p) }; its the return query that mess things up. I have checked and the culturename actually gets data from the database. Appricate your help

    Read the article

  • ASP.NET MVC <OutputCache> SqlDependency (CommandNotification?) with LINQ queries

    - by sinni800
    Hello, I use LINQ queries in my ASP.NET MVC application and want to use OutputCache in some of my Actions. I hear this should be possible with CommandNotifications. But those seem to only go for self-created SQLCommands, or am I wrong? Can I manually tell SQL server to send SQLDependency notifications if certain tables change? And if yes, how can I attach them to the OutputCache? Another side question: Can you do this with strongly types views too? Thank you in advance...

    Read the article

  • How dynamic can I make my LINQ To SQL Statements?

    - by mcass20
    I have the need to construct a LINQ To SQL statement at runtime based on input from a user and I can't seem to figure out how to dynamically build the WHERE clause. I have no problem with the following: string Filters = "<value>FOO</value>"; Where("FormattedMessage.Contains(@0)",Filters) But what I really need is to make the entire WHERE clause dynamic. This way I can add multiple conditions at runtime like this (rough idea): foreach (Filter filter in filterlist) { whereclause = whereclause + "&& formattedmessage.contains(filter)"; }

    Read the article

  • Using LINQ to XML, how can I join two sets of data based on ordinal position?

    - by Donald Hughes
    Using LINQ to XML, how can I join two sets of data based on ordinal position? <document> <set1> <value>A</value> <value>B</value> <value>C</value> </set1> <set2> <value>1</value> <value>2</value> <value>3</value> </set2> </document> Based on the above fragment, I would like to join the two sets together such that "A" and "1" are in the same record, "B" and "2" are in the same record, and "C" and "3" are in the same record.

    Read the article

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