Skip to content

LINQ

LINQ (all flavours)

This category can be followed from the open social web via the handle linq-e04cf296@forum.codeproject.com

783 Topics 2.8k Posts
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • LINQ to Entities - how to persist column order?

    tutorial csharp linq help question
    3
    0 Votes
    3 Posts
    2 Views
    D
    Well, it is obviously difficult to reproduce as effect is random. Sometimes it happens sometimes it does not.
  • Adding new column to LINQ to SQL table

    database announcement csharp linq question
    4
    0 Votes
    4 Posts
    5 Views
    T
    Don't edit the generated file or you're setting yourself up for a lot of pain. If you toot in the wrong directly Visual Studio may regenerate the file on it's own. :laugh: If you haven't done any customization on your dbml file, it is relatively painless to delete the table and drag it back onto your designer. The new column is added automatically. You can also do it by adding the column manually to the designer and setting the appropriate properties; you would need to do this if you've customized your property/table names or set up custom relationships etc. After changing/updating the designer, and after you build again, the new column will be in the rest of your classes. Cheers. They Call me Mister James
  • How to get records from XML based on input conditions [modified]

    xml tutorial
    3
    0 Votes
    3 Posts
    4 Views
    N
    Thanks for your reply. I tried your expression, it returned duplicate records. I tried the below, which is working.. Thank you once again for your post. lstRecords = uidDb.Descendants("Record").Where(r =>ApplyFilter(r, inputParams)).ToList(); private bool ApplyFilter(XElement record, List<Attribute> iParams) { foreach (Attribute param in iParams) { if (record.Element(param.Name).Value != param.Value) return false; } return true; }
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • Linq not opening

    help csharp linq design tutorial
    2
    0 Votes
    2 Posts
    4 Views
    K
    What do you mean by a Linq file? Are you referring to a .dbml file? Your question is not that clear... Cheers, Karthik
  • passing parameter

    database question
    2
    0 Votes
    2 Posts
    2 Views
    N
    If I understand you correctly, you want to take the 7 parameters that were passed in the querystring and resend them to the new page? If so, you need review your syntax because it's not doing anything close to what your intending.... 1) what is mytable? how does that relate to querystring variables? 2) link query returns an IEnumerable(of ???) list. You have a redirect in the where clause so why kind of response do you think you'll be getting when it needs to return an ienumerable(of ???) list? 3) where is any mention of request.querystring to go through it's dictionary? 'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
  • 0 Votes
    2 Posts
    2 Views
    N
    Thanks for sharing, but this isn't the place for it. Forums are for questions. I know the language. I've read a book. - _Madmatt
  • Interesting difference (operators vs expressions)

    visual-studio workspace
    4
    0 Votes
    4 Posts
    6 Views
    V
    It does switch :-), good point. Should have known really. V.
  • 0 Votes
    2 Posts
    2 Views
    D
    There are a few thrid party products available that will let you do LINQ to Oracle. There is nothing built into .Net for that AFAIK. Since I have not used any of them, I can not recommend you one. Maybe a trial download and some POC would help you decide.
  • trying to skip and jump elements in a list

    20
    0 Votes
    20 Posts
    8 Views
    D
    hey that's a nice solution. thanks for posting it :) I bug
  • Deferred loading in LinqToSql

    database question
    2
    0 Votes
    2 Posts
    2 Views
    T
    What kind of object is _bindingSource? My guess would be that it likely iterates through the data when DataSource is assigned to. You could create a var that holds the _context.VAllClients reference and only assign to _bindingSource when you're ready. They Call me Mister James
  • 0 Votes
    3 Posts
    4 Views
    V
    'Select many' , yeah got it. Thanks. StudentCollection studentColl = GetAllStudentCollection(); StudentSubjectCollection subjectColl = studentColl.SelectMany(field=>field.StudentSubjectCollection);
  • how to wait for ExecuteQuery to complete?

    database help csharp css sql-server
    7
    0 Votes
    7 Posts
    3 Views
    S
    Hi Fernando, No, that is not the setup. I have the DataContext intantiation and the call to ExecuteQuery in a separate function. More like this: public List<DataTable> callExecute() { DataClassesDataContext dc = new DataClassesDataContext(); List<DataTable> listReturn = dc.ExecuteQuery(strSQL); return listReturn; } // code that does time out ... listTemp = callExecute(); // these calls return counts with different date ranges int nCount1 = callExecute().Count(); int nCount2 = callExecute().Count(); // timeout happens during this call ... // code that does _not_ time out ... listTemp = callExecute().ToList(); System.Threading.Thread.Sleep(250); // these calls return counts with different date ranges int nCount1 = callExecute().Count(); System.Threading.Thread.Sleep(250); int nCount2 = callExecute().Count(); ... Thanks for your help.
  • DataGridView Cannot Edit

    database question
    3
    0 Votes
    3 Posts
    3 Views
    M
    You can also insert commandfield in the DataGridView.
  • LINQ To Datatable......................

    csharp database linq
    3
    0 Votes
    3 Posts
    2 Views
    E
    Hi! There is no way to do it directly. The first way to do it is fill entity at first and then use CopyToDataTable() method. Since you haven't had dbml file (dataContext) you can't do it. Or more complex you should write your own extension method which takes ExpressionTree and translates it in string represntation then simply use standard DataSet approach for DataTable filling. (Still it is very inconvinent) Generally speaking it is not good itdea to mix DataSet and LinqToSQL approach in one project. More here: http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/05996101-299e-423c-9137-e3b8d02890e1/
  • refresh context

    csharp linq help
    2
    0 Votes
    2 Posts
    2 Views
    S
    Have you tried to add the new record using the binding source. In that case the record should appear automatically in the datagrid, then accept changes in context and it should be written to database too.
  • Find missing elements

    database tutorial question
    3
    0 Votes
    3 Posts
    3 Views
    F
    Hi Collin; This can be done with linq as shown in the code snippet below. // Your values from Index property List<int> myElements = new List<int>() { 8, 5, 9, 3, 4 }; // Create all integers from min value to max value in above collection var range = from n in Enumerable.Range(myElements.Min(), myElements.Max() - myElements.Min() + 1) select n; // Find all missing values List<int> result = range.Except(myElements).ToList();
  • How To Convert This To Linq

    csharp asp-net linq help tutorial
    3
    0 Votes
    3 Posts
    4 Views
    F
    Let say that the instantiated data context is db, then you query in Linq would be as follows : var r2 = from rtgr in db.mmlaspnet_RolesToGlobalRoles select rtgr.RoleId; var r1 = from r in db.aspnet_Roles where r2.Contains(r.RoleId) orderby r.RoleName select r; fereach( var roles in r1 ) { Console.WriteLine("RoleID = {0} ....", role.RoleId, ...); }
  • Group By (another question)

    database com data-structures help tutorial
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied