Search Results

Search found 6048 results on 242 pages for 'linq to dataset'.

Page 9/242 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Convert this Linq query from query syntax to lambda expression

    - by Jinkinz
    I'm not sure I like linq query syntax...its just not my preference. But I don't know what this query would look like using lambda expressions, can someone help? from securityRoles in user.SecurityRoles from permissions in securityRoles.Permissions where permissions.SecurableEntity.Name == "Unit" && permissions.PermissionType.Name == "Read" orderby permissions.PermissionLevel.Value descending select permissions There is a many-to-many relationship between users and security roles that makes this extra confusing. Thanks! Kelly

    Read the article

  • sql to xml using linq - nested collections

    - by nelsonwebs
    I have a table of data that looks something like this. name, hour, price1, price2, price3, price4, price5 fred, 3, 12.5, 13.5, 14, 15, 16 dave, 6, 8, 12, 18, 20.2, 25 fred, 6, 10, 11, 14, 15, 19.7 This table needs to be output to an xml file that looks like this. <timeCost> <person name="fred"> <time hour="5"> <cost price="12.5" /> <cost price="13.5" /> <cost price="14" /> <cost price="15" /> <cost price="16" /> </time> <time hour="6"> <cost price="10" /> <cost price="11" /> <cost price="14" /> <cost price="15" /> <cost price="19.7" /> </time> </person> <person name="dave"> <time hour="6"> <cost price="8" /> <cost price="12" /> <cost price="18" /> <cost price="20.2" /> <cost price="25" /> </time> </person> </timeCost> I have a linq query to get the data from SQL something like this. // initialize data context var people = from p in dc.people orderby p.name, p.hour select p; However, I'm having trouble writing the xml out using linq (csharp). Specifically, the problem is I don't know how to deal with having multiple time nodes under each name node (nested loops/collections). How can this be done? This is a sql 08 ent db if it matters to anyone.

    Read the article

  • Select most recent records using LINQ to Entities

    - by begemotya
    I have a simple Linq to Enities table to query and get the most recent records using Date field So I tried this code: IQueryable<Alert> alerts = GetAlerts(); IQueryable latestAlerts = from a in alerts group a by a.UpdateDateTime into g select g.OrderBy(a = a.Identifier).First(); Error: NotSupportedException: The method 'GroupBy' is not supported. Is there any other way to get do it? Thanks a lot!

    Read the article

  • LINQ: Create persistable Associations in Code, Without Foreign Key

    - by Alex
    Hello, I know that I can create LINQ Associations without a Foreign Key. The problem is, I've been doing this by adding the [Association] attribute in the DBML file (same as through the designer), which will get erased again after I refresh my database (and reload the entire table structure). I know that there is the MyData.cs file (as part of the DBML) in which I can place my partial extensions etc. to domain objects (to persist even after I refresh the DBML), but I don't know how to create an association there?

    Read the article

  • 'Contains()' workaround using Linq to Entities?

    - by jbloomer
    I'm trying to create a query which uses a list of ids in the where clause, using the Silverlight ADO.Net Data Services client api (and therefore Linq To Entities). Does anyone know of a workaround to Contains not being supported? I want to do something like this: List<long?> txnIds = new List<long?>(); // Fill list var q = from t in svc.OpenTransaction where txnIds.Contains(t.OpenTransactionId) select t;

    Read the article

  • C# & ASP.Net - determine linq query generation time

    - by Chris Klepeis
    I'd like to detemine the amount of time it takes for my ASP.Net program to generate certain sql queries using linq.... note - I want the query generation time, not the query execution time. Is this possible, or even feasable (if its usually fast)? My website has some heavy traffic and I want to cover all of my bases.

    Read the article

  • Add elements to XDocument after LINQ Query

    - by Jon
    I have the following XML LINQ query from my XDocument. var totals = (from x in MyDocument.Descendants("TOTALS") select x).FirstOrDefault(); Once I have found my totals node I need to add some elements to that node and push that change to the XDocument.

    Read the article

  • LINQ to SQL associations - how to change the value of associated field

    - by HAdes
    I have 2 classes with a LINQ association between them i.e.: Table1: Table2: ID ID Name Description ForiegnID The association here is between Table1.ID - Table2.ForiegnID I need to be able to change the value of Table2.ForiegnID, however I can't and think it is because of the association (as when I remove it, it works). Therefore, does anyone know how I can change the value of the associated field Table2.ForiegnID? Thanks.

    Read the article

  • Stored Functions with Linq to Entities

    - by Lawnmower
    Hi, How can I make a MS-SQL stored function availabe in LINQ expressions if using the Entity framework? The SQL function was created with CREATE FUNCTION MyFunction(@name) ...). I was hoping to access it similarly to this: var data = from c in entities.Users where MyFunction(c.name) = 3; Unfortunately I have only .NET 3.5 available.

    Read the article

  • LinQ: Add list to a list

    - by JohannesBoersma
    I have the following code: var columnNames = (from autoExport in dataContext.AutoExports where autoExport.AutoExportTemplate != null && ContainsColumn(autoExport.AutoExportTemplate, realName) select GetDbColumnNames(autoExport.AutoExportTemplate, realName)).ToList(); Where the function GetDbColumns() returns an List<string>. So columNames is of the type List<List<string>>. Is it possible to create a List<string>, so each element of the list of GetDbColumns is added to the result of the LinQ query?

    Read the article

  • Encrypt column data with LINQ

    - by kape123
    I was wondering if there is easy solution to this or I'm stuck with following: When updating DB: dti.Pass = Crypter.Encrypt(dti.Pass); _db.SubmitChanges(); When selecting from DB: Data.DbTableItem dti = _db.Single(a=a.Id == id); dti.Pass = Crypter.Decrypt(dti.Pass); Meaning - I am not really into writing repetitive code and this seems like logical thing to be supported by LINQ; so I'm wondering if it is.

    Read the article

  • How do I properly use LINQ with MySQL?

    - by Arda Xi
    I've been looking this up on Google for hours, but I haven't found anything conclusive. So far, I've seen a few paid options, an option with NHibernate, but most are marked as unstable or in production. Is there a stable implementation of LINQ for MySQL?

    Read the article

  • compiling a linq to sql query

    - by frenchie
    Hi, I have queries that are built like this: public static List<MyObjectModel> GetData (int MyParam) { using (DataModel MyModelDC = new DataModel()) { var MyQuery = from.... select MyObjectModel { ...} } return new List<MyObjectModel> (MyQuery) } } It seems that using compiled linq-to-sql queries are about as fast as stored procedures and so the goal is to convert these queries into compiled queries. What's the syntax for this? Thanks.

    Read the article

  • Linq with EF dynamic search

    - by malik
    I am using EF 3.5 with MVC. I want to made a search page, has some fields for criteria like date, int etc. What is the way in linq to entities to filter the result dynamically. If there are one parameter we can use .where(a=a.id==1) but many combination with optional param how can i load results and then pass to model.

    Read the article

  • LINQ TO SQL, Dynamic query with DATE type fields

    - by acanthus
    Hello, I'm building a query with the LINQ dynamic library so I don't know how many potential parameters will I have and I get an error when trying to query DATE type fields: Operator '=' incompatible with operand types 'DateTime' and 'String' When I step through the debugger in the Dynamic.cs it shows that the value is of type string and the field is of type date so the problem is obvious but I have no idea how to approach it. Any ideas? BR

    Read the article

  • Translate LINQ to sql statement

    - by zielu1
    Hi, I want to translate LINQ expression tree to SQL statement and I don't want to write my own code for this. Example: var query = from c in Customers where c.Country == "UK" && c.City == "London" select c); To SELECT ... FROM Customers AS c WHERE c.Country = "UK" AND c.City = "London" I know DataContext.Log, but I want to use: query.ToSqlStatementString() Thanks

    Read the article

  • Order by descending based on condition

    - by Vinni
    Hello All, I want to write a LINQ to Entity query which does order by ascending or descending based on input parameter, Is there any way for that. Following is the my code. Please suggest. public List<Hosters_HostingProviderDetail> GetPendingApproval(SortOrder sortOrder) { List<Hosters_HostingProviderDetail> returnList = new List<Hosters_HostingProviderDetail>(); int pendingStateId = Convert.ToInt32(State.Pending); //If the sort order is ascending if (sortOrder == SortOrder.ASC) { var hosters = from e in context.Hosters_HostingProviderDetail where e.ActiveStatusID == pendingStateId orderby e.HostingProviderName ascending select e; returnList = hosters.ToList<Hosters_HostingProviderDetail>(); return returnList; } else { var hosters = from e in context.Hosters_HostingProviderDetail where e.StateID == pendingStateId orderby e.HostingProviderName descending select e; returnList = hosters.ToList<Hosters_HostingProviderDetail>(); return returnList; } }

    Read the article

  • how to convert Database Hierarchical Data to XML using ASP.net 3.5 and LINQ

    - by mahdiahmadirad
    hello guys! i have a table with hierarchical structure. like this: and table data shown here: this strategy gives me the ability to have unbounded categories and sub-categories. i use ASP.net 3.5 SP1 and LINQ and MSSQL Server2005. How to convert it to XML? I can Do it with Dataset Object and ".GetXML()" method. but how to implement it with LINQtoSQL or LINQtoXML??? or if there is another simpler way to perform that? what is your suggestion? the best way? I searched the web but found nothing for .net 3.5 featuers.

    Read the article

  • Repository vs Data Access

    - by vdh_ant
    Hi guys In the context of the n-tier application, is there a difference between what you would consider your data access classes to be and your repositories? I tend to think yes but I just wanted to see what other thought. My thinking is that the job of the repository is just to contain and execute the raw query itself, where as the data access class would create the context, execute the repository (passing in the context), handle mapping the data model to the domain model and return the result back up... What do you guys think? Also do you see any of this changing in a Linq to XML scenario (assuming that you change the context for the relevant XDocument)? Cheers Anthony

    Read the article

  • Instantiate object from Linq to XML Query

    - by objectsbinding
    Hi All I have the following class public class CountrySpecificPIIEntity { public string Country { get; set; } public string CreditCardType { get; set; } public String Api { get; set; } public List<String> FilterList { get; set; } } I am trying to use a linq to XMl query to create a list of instances of type CountrySpecificPIIEntity. The XML is as below <piisettings> <country countrycode="DE"> <creditcardype credicardtype="mastercard"> <api api="INSERT_FILTERS"> <filters> <filter>FIRSTNAME</filter> <filter>HOUSENUMBER</filter> <filter>ADDITIONALADDRESSINFO</filter> <filter>EMAIL</filter> </filters> </api> </creditcardype> <creditcardype credicardtype="visa"> <api api="INSERT_FILTERS"> <filters> <filter>STATE</filter> <filter>EMAIL</filter> </filters> </api> </creditcardype> <creditcardype credicardtype="visa"> <api api="UPDATE_FILTERS"> <filters> <filter>STATE</filter> <filter>EMAIL</filter> </filters> </api> </creditcardype> </country> <country countrycode="GB"> <creditcardype credicardtype="americanexpress"> <api api="INSERT_FILTERS"> <filters> <filter>STREET</filter> <filter>ZIP</filter> <filter>CITY</filter> <filter>STATE</filter> <filter>EMAIL</filter> </filters> </api> </creditcardype> <creditcardype credicardtype="debank"> <api api="INSERT_FILTERS"> <filters> <filter>IPADDRESSCUSTOMER</filter> <filter>FIRSTNAME</filter> <filter>SURNAME</filter> <filter>HOUSENUMBER</filter> <filter>STREET</filter> <filter>ZIP</filter> <filter>CITY</filter> <filter>STATE</filter> <filter>EMAIL</filter> </filters> </api> </creditcardype> </country> </piisettings> what should the Linq to XML query be?

    Read the article

  • Why is the use of abstractions (such as LINQ) so taboo?

    - by Matthew Patrick Cashatt
    I am an independent contractor and, as such, I interview 3-4 times a year for new gigs. I am in the midst of that cycle now and got turned down for an opportunity even though I felt like the interview went well. The same thing has happened to me a couple of times this year. Now, I am not a perfect guy and I don't expect to be a good fit for every organization. That said, my batting average is lower than usual so I politely asked my last interviewer for some constructive feedback, and he delivered! The main thing, according to the interviewer, was that I seemed to lean too much towards the use of abstractions (such as LINQ) rather than towards lower-level, organically grown algorithms. On the surface, this makes sense--in fact, it made the other rejections make sense too because I blabbed about LINQ in those interviews as well and it didn't seem that the interviewers knew much about LINQ (even though they were .NET guys). So now I am left with this question: If we are supposed to be "standing on the shoulders of giants" and using abstractions that are available to us (like LINQ), then why do some folks consider it so taboo? Doesn't it make sense to pull code "off the shelf" if it accomplishes the same goals without extra cost? It would seem to me that LINQ, even if it is an abstraction, is simply an abstraction of all the same algorithms one would write to accomplish exactly the same end. Only a performance test could tell you if your custom approach was better, but if something like LINQ met the requirements, why bother writing your own classes in the first place? I don't mean to focus on LINQ here. I am sure that the JAVA world has something comparable, I just would like to know why some folks get so uncomfortable with the idea of using an abstraction that they themselves did not write. UPDATE As Euphoric pointed out, there isn't anything comparable to LINQ in the Java world. So, if you are developing on the .NET stack, why not always try and make use of it? Is it possible that people just don't fully understand what it does?

    Read the article

  • Are there any good resources for refactoring existing C# code to use LINQ while keeping your tests passing?

    - by Paddyslacker
    I've been teaching myself a little LINQ and an exercise I thought would be useful was to take my existing Project Euler C# code, which I built using Test Driven Development and gradually convert it to LINQ. I realise that LINQ is not always the best solution for all of the Project Euler problems, but I don't want to get into that here. I'm wondering whether or not it's feasible to refactor "traditional" OO C# code to use LINQ and functional programming syntax whilst keeping all of your tests passing. I can't find a way to make the tiny steps I'm used to making using TDD when converting to LINQ and this is a roadblock for me. I seem to have to make large changes to come up with a single function that I then replace whole chunks of my code with. I realise I could write this from scratch in LINQ, but in the real world, I'd like to be able to replace parts of my existing C# code to take advantage of LINQ where appropriate. Has anyone been successful with this approach? What resources did you find useful for refactoring existing C# code to use LINQ whilst taking a Test Driven Development approach?

    Read the article

  • Linq2sql code generator misbehaving

    - by Martin
    Sometime the linq2sql just makes its mind up about things. I've been pulling my hair for the past hours trying to work out what I'm doing differently from all the other times when I don't get ForeignKeyReferenceAlreadyHasValueException. Turns out that if (this._Activity.HasLoadedOrAssignedValue) { throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); } is present on my primary key in this particular table, and in no other. No matter what I do with the association, I've even tried deleting and dragging the thing back to the designer, it's still there and I'm sure it's not supposed to be. I know why, of course, but I don't know why, so to speak. A while back the association went the other way. Whereas I've left that era behind me, the code generator seems to exhibit phantom pains. The same phenomenon, is responsible for me having to change the namespace in the designer.cs everytime I make changes in the designer. I made the mistake of renaming my namespace and the code generator just doesn't get it. Somebody please help this poor boy out.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >