Search Results

Search found 6744 results on 270 pages for 'linq to entities'.

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

  • The specified type member 'EntityKey' is not supported in LINQ to Entities

    - by user300992
    I have 2 Entities "UserProfile" and "Agent", they are 1-many relationship. I want to do a query to get a list of Agents by giving the userProfileEntityKey. When I run it, I got this "The specified type member 'EntityKey' is not supported in LINQ to Entities" error. public IQueryable<Agent> GetAgentListByUserProfile(EntityKey userProfileEntityKey) { ObjectQuery<Agent> agentObjects = this.DataContext.AgentSet; IQueryable<Agent> resultQuery = (from p in agentObjects where p.UserProfile.EntityKey == userProfileEntityKey select p); return resultQuery; } So, what is the correct way to do this? Do I use p.UserProfile.UserId = UserId ? If that's the case, it's not conceptual anymore. Or should I write object query instead of LINQ query?

    Read the article

  • Can one prevent Genshi from parsing HTML entities?

    - by DNS
    I have the following Python code using Genshi (simplified): with open(pathToHTMLFile, 'r') as f: template = MarkupTemplate(f.read()) finalPage = template.generate().render('html', doctype = 'html') The source HTML file contains entities such as &copy;, &trade; and &reg;. Genshi replaces these with their UTF-8 character, which causes problems with the viewer (the output is used as a stand-alone file, not a response to a web request) that eventually sees the resulting HTML. Is there any way to prevent Genshi from parsing these entities? The more common ones like &amp; are passed through just fine.

    Read the article

  • Why can't I reference child entities with part of the parent entities composite key

    - by tigermain
    I am trying to reference some child entities with part of the parents composite key not all of it, why cant I? This happens when I use the following mapping instead of that which is commented. I get the following error Foreign key in table VolatileEventContent must have same number of columns as referenced primary key in table LocationSearchView <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="JeanieMaster.Domain.Entities" assembly="JeanieMaster.Domain"> <class name="LocationSearchView" table="LocationSearchView"> <composite-id> <key-property name="LocationId" type="Int32"></key-property> <key-property name="ContentProviderId" type="Int32"></key-property> <key-property name="CategoryId" type="Int32"></key-property> </composite-id> <property name="CompanyName" type="String" not-null="true" update="false" insert="false"/> <property name="Description" type="String" not-null="true" update="false" insert="false"/> <property name="CategoryId" type="Int32" not-null="true" update="false" insert="false"/> <property name="ContentProviderId" type="Int32" not-null="true" update="false" insert="false"/> <property name="LocationId" type="Int32" not-null="true" update="false" insert="false"/> <property name="Latitude" type="Double" update="false" insert="false" /> <property name="Longitude" type="Double" update="false" insert="false" /> <bag name="Events" table="VolatileEventContent" where="DeactivatedOn IS NULL" order-by="StartDate DESC" lazy="false" cascade="none"> <key> <column name="LocationId"></column> <column name="ContentProviderId"></column> <!--<column name="LocationId"></column> <column name="ContentProviderId"></column> <column name="CategoryId"></column>--> </key> <one-to-many class="Event" column="VolatileEventContentId"></one-to-many> </bag> </class> </hibernate-mapping> And VolatileEventContent mapping file <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="JeanieMaster.Domain.Entities" assembly="JeanieMaster.Domain"> <class name="Event" table="VolatileEventContent" select-before-update="false" optimistic-lock="none"> <composite-id> <key-property name="LocationId" type="Int32"></key-property> <key-property name="ContentProviderId" type="Int32"></key-property> </composite-id> <property name="Description" type="String" not-null="true" update="false" insert="false"/> <property name="StartDate" type="DateTime" not-null="true" update="false" insert="false" /> <property name="EndDate" type="DateTime" not-null="true" update="false" insert="false" /> <property name="CreatedOn" type="DateTime" not-null="true" update="false" insert="false" /> <property name="ModifiedOn" type="DateTime" not-null="false" update="false" insert="false" /> <many-to-one name="Location" class="Location" column="LocationId" /> <bag name="Artistes" table="EventArtiste" lazy="false" cascade="none"> <key name="VolatileEventContentId" /> <many-to-many class="Artiste" column="ArtisteId" ></many-to-many> </bag> </class> </hibernate-mapping>

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

  • 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

  • Converting F# Quotations into LINQ Expressions

    - by forki23
    Hi, I can convert a quotation of type Expr<'a -> 'b> to a Linq expression via the following snippet: /// Converts a F# Expression to a LINQ Lambda let toLambda (exp:Expr) = let linq = exp.ToLinqExpression() :?> MethodCallExpression linq.Arguments.[0] :?> LambdaExpression /// Converts a Lambda quotation into a Linq Lamba Expression with 1 parameter let ToLinq (exp : Expr<'a -> 'b>) = let lambda = toLambda exp Expression.Lambda<Func<'a, 'b>>(lambda.Body, lambda.Parameters) Now I want to convert a quotation of type Expr<'a * 'b -> 'c> or maybe even Expr<'a -> 'b -> 'c> to a Linq Lambda Expression of type Expression<Func<'a,'b'c>>. How can I do this? Regards, forki

    Read the article

  • Linq to Entities performance within ASP.NET Development Server

    - by tster
    I've been evaluating linq to entities and linq to SQL for a project. Obviously each has its own advantages and disadvantages which have been discussed plenty of times here. However, One thing I am seeing with L2E is kind of odd. Using L2S, when using the ASP.NET Development Server, the performance is a little slower for my web service calls. I'm looking at 300ms vs. 250 ms. However, when using L2E, when using ASP.NET Dev Server, the performance is awful. I'm talking 1,250 ms vs. 220 ms. I know I should probably just use local IIS for development, but I'm curious if anyone else has seen this, or knows what is causing it.

    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

  • How to design database having multiple interrelated entities

    - by Sharath Chandra
    I am designing a new system which is more of a help system for core applications in banks or healthcare sector. Given the nature of the system this is not a heavy transaction oriented system but more of read intensive. Now within this application I have multiple entities which are related to each other. For e.g. Assume the following entities in the system User Training Regulations Now each of these entities have M:N Relationship with each other. Assuming the usage of a standard RDBMS, the design may involve many relationship tables each containing the relationships one other entity ("User_Training", "User_Regulations", "Training_Regulations"). This design is limiting since I have more than 3 entities in the system and maintaining the relationship graph is difficult this way. The most frequently used operation is "given an entity get me all the related entities" . I need to design the database where this operation is relatively inexpensive. What are the different recommendations for modelling this kind of database.

    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

  • linq to xml. read. and assign to ViewData..noob

    - by raklos
    I have some xml similar to this: <?xml version="1.0" encoding="utf-8" ?> <data> <resources> <resource key="Title">Alpha</resource> <resource key="ImageName">Small.png</resource> <resource key="Desc">blah</resource> </resources> </data> using linq-xml how can i assign each resource here as a key value pair with the ViewData collection. Thanks.

    Read the article

  • How to get List of results from list of ID values with LINQ to SQL?

    - by DaveDev
    I have a list of ID values: List<int> MyIDs { get; set; } I'd like to pass this list to an interface to my repository and have it return a List that match the ID values I pass in. List<MyType> myTypes = new List<MyType>(); IMyRepository myRepos = new SqlMyRepository(); myTypes = myRepos.GetMyTypes(this.MyIDs); Currently, GetMyTypes() behaves similarly to this: public MyType GetMyTypes(int id) { return (from myType in db.MyTypes where myType.Id == id select new MyType { MyValue = myType.MyValue }).FirstOrDefault(); } where I iterate through MyIDs and pass each id in and add each result to a list. How do I need to change the LINQ so that I can pass in the full list of MyIDs and get a list of MyTypes out? GetMyTypes() would have a signature similar to public List<MyType> GetMyTypes(List<int> myIds)

    Read the article

  • LINQ-to-XML to DataGridView: Cannot edit fields -- How to fix?

    - by Pretzel
    I am currently doing LINQ-to-XML and populating a DataGridView with my query just fine. The trouble I am running into is that once loaded into the DataGridView, the values appear to be Un-editable (ReadOnly). Here's my code: var barcodes = (from src in xmldoc.Descendants("Container") where src.Descendants().Count() > 0 select new { Id = (string)src.Element("Id"), Barcode = (string)src.Element("Barcode"), Quantity = float.Parse((string)src.Element("Quantity").Attribute("value")) }).Distinct(); dataGridView1.DataSource = barcodes.ToList(); I read somewhere that the "DataGridView will be in ReadOnly mode when you use Anonymous types." But I couldn't find an explanation why or exactly what to do about it. Any ideas?

    Read the article

  • Extending LINQ classes to my own partial classes in different namespaces?

    - by sah302
    I have a .dbml file which of course contains the auto-generated classes based on my tables. I would however, like to extend them to my own classes. Typically I design such that each of my tables get their own namespace in their own folder containing all of their associated dao and service classes. So if I am dealing with a page that only has to do with 'customers' for instance, I can only include the customerNS. But when using LINQ I seem to be unable to do this. I have tried removing a default namespace from the project, I have tried putting the .dbml file into it's own folder with a custom namespace and then adding a 'using' statement, but no nothing works. I also saw the Entity Namespace, Context Namespace, and Custom Tool Namespace properties associated with the .dbml file and tried setting all these to names x and trying 'using x' in my other class to allow me to extend partial classes, but it just doesn't work. Is this possible or do I have to keep all extended partial classes in the same namespace as the .dbml file?

    Read the article

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