Search Results

Search found 18661 results on 747 pages for 'linq to mysql'.

Page 107/747 | < Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >

  • Linq to object - Select Distinct

    - by Ben
    Hi, I can't quite figure out why this Linq Statement isn't working as i would expect: Dim distinctSurchargesList = (From thisparent As Parent In ThisParentCollection _ From thisChild As Child In thisparent.theseChildren _ Select New With {.childId = thischild.Id}).Distinct() I would assume that this would create a new collection of anonymous types, that would be distinct. Instead it creates a collection the size of the "ThisParentCollection" with duplicate "MyAnonymousType" in it (duplicate id's). Can anyone tell me where im going wrong? Thanks

    Read the article

  • Convert query from native SQL to LINQ request

    - by mike
    Please, help me. How i can translate this SQL query to LINQ request? SELECT TOP (1) PERCENT DATEDIFF(DAY, dbo.PO.ORDER_DATE, GETDATE()) AS Age FROM dbo.ITEMS INNER JOIN dbo.X_PO ON dbo.ITEMS.ITEMNO = dbo.X_PO.ITEM_CODE INNER JOIN dbo.PO ON dbo.X_PO.ORDER_NO = dbo.PO.DOC_NO AND dbo.X_PO.STATUS = dbo.PO.STATUS WHERE (dbo.ITEMS.ITEMNO = 'MBIN001') AND (dbo.X_PO.STATUS = 3) ORDER BY Age

    Read the article

  • linq where clause not in select statement

    - by Annie
    Can someone help me to convert from SQL Query to LINQ VB.NET: select rls.* from Roles rls(nolock) where rls.id not in ( select r.ID from usersRole ur (nolock) inner join Roles r(nolock) on ur.RoleID = r.ID where user_id = 'NY1772') Thanks

    Read the article

  • LINQ Equivalent for Standard Deviation

    - by Steven
    Does LINQ model the aggregate SQL function STDDEV() (standard deviation)? If not, what is the simplest / best-practices way to calculate it? Example: SELECT test_id, AVERAGE(result) avg, STDDEV(result) std FROM tests GROUP BY test_id

    Read the article

  • ASP.NET LINQ to Delete Rows

    - by Tyler
    Dim db As New SQLDataContext Try Dim deleteBoatPics = (From boat In db.Photos Where boat.boatid = id) db.Photos.DeleteOnSubmit(deleteBoatPics) db.SubmitChanges() Catch ex As Exception End Try I'm getting an error that says: Unable to cast object of type 'System.Data.Linq.DataQuery`1[WhiteWaterPhotos.Photo]' to type 'WhiteWaterPhotos.Photo'. I have two separate db.SubmitChanges() because when the button is pressed, I have it delete the records from 1 table, and then the next. I'm lost, can someone help me out?

    Read the article

  • LINQ dynamic query

    - by ile
    How to dynamically generate LINQ query: int[] IDArray = {55, 36}; public IQueryable<ContactListView> FindAllContacts(int loggedUserID, int[] IDArray) { var result = ( from contact in db.Contacts //Start of dynamic part... where contact.UserID == loggedUserID foreach (var id in IDArray) { where contact.UserID == id } // End of dynamic part orderby contact.ContactID descending select new ContactListView { ContactID = contact.ContactID, FirstName = contact.FirstName, LastName = contact.LastName }); return result; } Thanks, Ile

    Read the article

  • LINQ to NETEZZA

    - by CraigS
    Does anyone know if it is possible to use LINQ to query a NETEZZA back-end? Update: I've tried both the ODBC and OLEDB Netezza drivers, but neither work. Both give a "The selected object(s) use an unsupported data source" error.

    Read the article

  • like operator in linq

    - by Luca Romagnoli
    i need to use the like operator in a linq query for this: timb = time.Timbratures.Include("Anagrafica_Dipendente") .Where(p => p.Anagrafica_Dipendente.Cognome + " " + p.Anagrafica_Dipendente.Nome like "%ci%"); How can i do?

    Read the article

  • bind linq expression

    - by Neir0
    Hi, I have a ListView and ObservableCollection in my wpf application. I want to bind linq expression to ListView: lv_Results.DataContext = store.Where(x => x.PR > 5); But when i add new elements to store collection, lv_Results doesnt updates. How can i update ListView?

    Read the article

  • C# Outer Apply in LINQ

    - by JeremySpouken
    How can I achieve Outer Apply in LINQ? I'm having a bit of a problem. Here's the SQL Query I'm using. SELECT u.masterID ,u.user ,h.created FROM dbo.Users u OUTER APPLY (SELECT TOP 1 * FROM UserHistory h where h.masterID = u.masterID ORDER BY created DESC) h

    Read the article

  • LINQ Guid toString()

    - by Sevki
    Hi this seems like it should work, from something in collectionofsomestuff select new SelectListItem(){Text = Name, Value = SomeGuid.ToString(), Selected = false}; When I try to do this it doesn't work give me error LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression. Is there a workaround?

    Read the article

  • LINQ group by and getting latest value

    - by gregmac
    Say I have a structure like: class SomeObject Public Name as String Public Created as Date ... end class I have a List(of SomeObject), which has multiple entries for each name with different times. I'd like to select the newest (largest Created value) object for each Name. Given: Name Created A 2010-04-16 * A 2010-04-15 B 2010-04-12 B 2010-04-13 * C 2010-04-16 * I'd like to pick the objects with the * beside them. Is this possible using LINQ?

    Read the article

  • Cast LINQ Function Result to Domain Object

    - by Alex
    Hello, I have a table valued function to perform full text search on SQL server. The result type of my full text search function in LINQ is a special autogenerated type which includes KEY and RANK in addition to my regular domain object properties. So, if my regular domain object is PERSONS (with properties FirstName, LastName etc.), I also have a result object PERSONS_FTSResult with the same properties + KEY and RANK. Is there an easy way to cast it back to PERSONS?

    Read the article

  • Using Linq to concatenate strings

    - by tags2k
    What is the most efficient way to write the old-school: StringBuilder sb = new StringBuilder(); if (strings.Count > 0) { foreach (string s in strings) { sb.Append(s + ", "); } sb.Remove(sb.Length - 2, 2); } return sb.ToString(); ...in Linq?

    Read the article

  • LINQ-to-SQL - C# - OnValidate()

    - by Mark Comix
    Hello, I have a system with 3 layers and I am using LINQ-to-SQL to persist. I want to validate if the description field of my object is empty. I am using partial classes and the method OnValidate(). If the field is empty, it throws an exception. Is this correct? What do I do after the exception to not close the form, letting the user continue working? Thank you very much Sorry for my poor english

    Read the article

  • LINQ timed out while the same query works great in SQL

    - by oshafran
    Hi I am getting Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. When I run the SAME query in the SQL query program I get result within seconds, and in LINQ it takes forever and fails. What can cause this??? Thanks!

    Read the article

  • Override Linq-to-Sql Datetime.ToString() Default Convert Values

    - by snmcdonald
    Is it possible to override the default CONVERT style? I would like the default CONVERT function to always return ISO8601 style 126. Steps To Reproduce: DROP TABLE DATES; CREATE TABLE DATES ( ID INT IDENTITY(1,1) PRIMARY KEY, MYDATE DATETIME DEFAULT(GETUTCDATE()) ); INSERT INTO DATES DEFAULT VALUES; INSERT INTO DATES DEFAULT VALUES; INSERT INTO DATES DEFAULT VALUES; INSERT INTO DATES DEFAULT VALUES; SELECT CONVERT(NVARCHAR,MYDATE) AS CONVERTED, CONVERT(NVARCHAR(4000),MYDATE,126) AS ISO, MYDATE FROM DATES WHERE MYDATE LIKE'Feb%' Output: CONVERTED ISO MYDATE --------------------------- ---------------------------- ----------------------- Feb 8 2011 12:17AM 2011-02-08T00:17:03.040 2011-02-08 00:17:03.040 Feb 8 2011 12:17AM 2011-02-08T00:17:03.040 2011-02-08 00:17:03.040 Feb 8 2011 12:17AM 2011-02-08T00:17:03.040 2011-02-08 00:17:03.040 Feb 8 2011 12:17AM 2011-02-08T00:17:03.040 2011-02-08 00:17:03.040 Linq-to-Sql calls CONVERT(NVARCHAR,@p) when I cast ToString(). However, I am displaying all my data in the ISO8601 format. I would like to override the database default if possible to CONVERT(NVARCHAR,@p,126). I am using Dynamic Linq-to-Sql as demoed by ScottGu to process my data. PropertyInfo piField = typeof(T).GetProperty(rule.field); if (piField != null) { Type typeField = piField.PropertyType; if (typeField.IsGenericType && typeField.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) { filter = filter .Select(x => x) .Where(string.Format("{0} != null", rule.field)) .Where(string.Format("{0}.Value.ToString().Contains(\"{1}\")", rule.field, rule.data)); } else { filter = filter .Select(x => x) .Where(string.Format("{0} != null", rule.field)) .Where(string.Format("{0}.ToString().Contains(\"{1}\")", rule.field, rule.data)); } } I was hoping my property would convert the expression from CONVERT(NVARCHAR,@p) to CONVERT(NVARCHAR,@p,126), however I get a NotSupportedException: ... has no supported translation to SQL. public string IsoDate { get { if (SUBMIT_DATE.HasValue) { return SUBMIT_DATE.Value.ToString("o"); } else { return string.Empty; } } }

    Read the article

< Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >