|
|
-
Dear All, I am using storesprocedure to get multiple table results. how to bind the multiple result to Dataset or datatable? please anyone give me the solution ..... CREATE PROCEDURE [dbo] . [SP_GETMASTERDETAILS] AS BEGIN --Table1 - DEPARTMENT DETAILS SELECT [DeptId] , [Department_Code] , [Depart_Name] FROM EMP_DEPARTMENT_MASTER --Table2 -DESIGNATION DETAILS SELECT [DesignationID] , [DesignationName] FROM EMP_DESIGNATION_MASTER END [ Function (Name= "dbo.SP_GETMASTERDETAILS" )] [ ResultType ( typeof Read More...
|
-
Hi I am attempting to write myself a DAL rather than simply use the SQLMetal generated one. Overall I'm doing well, but have hit upon a snag whereby Linq doesn't appear to be able to Cast from a string into one of my own home grown objects which exist within the DAL entity. An example. Code Snippet public class MyEntity { private System.Guid _PrimaryKey; [Column(Name = "ProviderID", Storage = "_PrimaryKey")] public System.Guid PrimaryKey { get { return _PrimaryKey; } } private System.String _myLookupField; Read More...
|
-
Hi All The following SQL syntax retrieves the correct record in my database: select top 1 max ( createddate ), documentpath from App_UsersDocuments where DocumentTypeID = 1 and userid=@userid group by documentpath but i am struggling to translate this into linq. I have the following code: Dim dd = ( From d In db.App_UsersDocuments Where d.UserID = userid And d.DocumentTypeID = documenttypeid Select d).ToList Return dd but dont know the correct syntax to get the most recent document as specified by Read More...
|
-
Hi. How can I do a group by in LINQ to SQL... I do not want to use a stored procedure and the documentation for Group By just does not help me enough.... I have a table called songs, artist and then songs2artists. I want to get all songs and artists but group them by songs(A song can be a cover version by a few artists) so I thought of using FirstOrDefault but the problem is that a song - artist can be repeated 5 times, each for a different record label. The LINQ that i have to get my result set Read More...
|
-
OK, how do I get a NEW row of data to an existing table? Books and other web pages reference code like this: using(LogicorModel.LogicorEntities LDB = new LogicorModel.LogicorEntities()) { LogicorTrans lt = new LogicorTrans { PackageID = logT.PackageID, CarrierCode = logT.CarrierCode, ServiceCode = logT.ServiceCode, TrackingNumber = logT.TrackingNumber, LabelDT = logT.LabelDT, ShipperFee = logT.ShipperFee, FuelSurcharge = logT.FuelSurcharge, PackageShippedDT = DateTime.Now, Duties = logT.Duties, Fees Read More...
|
-
I received error message: Unable to cast object of type 'System.Data.EnumerableRowCollection`1[VB$AnonymousType_0`2[System.Collections.Generic.IEnumerable`1[System.Char],System.Collections.Generic.IEnumerable`1[System.Char]]]' to type 'System.Collections.Generic.IEnumerable`1[VB$AnonymousType_1`2[System.Collections.Generic.IEnumerable`1[System.Char],System.Collections.Generic.IEnumerable`1[System.Char]]]'. I am trying to use one of the field value from the first query as the criteria of where clause Read More...
|
-
Hi everyone! I'm kind of new to the LINQ world and came to a few problems with an application that I write (tried to ask this before, but I think I didn't make my problem clear enough). I have two classes derived from object, A and B. B has a member that holds a reference to an A object and some extra content (that is for internal purposes only). Additionally I have a list (let's call it L) that is derived from "List(Of B)". This list class holds two conversion methods (A to B conversion and B to Read More...
|
-
I've got a parse tree structure that I am traversing using recursion in order to find all descendant nodes of a given type. It seems like the same should be possible with Linq but I can't figure out the syntax (still wrapping my head around the syntactical brain thunk between Linq and good old procedural programming). My recursive method looks like so: Code Snippet class NonTerminalNode : SyntaxNode { private List m_array = new List(); protected List FindDescendants() where T : NonTerminalNode { Read More...
|
-
Hi, We are using LINQtoSQL class in VS 2008 to connect to the database and to perform Insert, Update and Delete operations in GridView. We are using the following code in LINQ Application. Public Class DbAccess Public Function FillWorkflows() As Table(Of Workflow) dc = New DataContext(New SqlConnection(sConnectionString)) Return dc.GetTable(Of Workflow)() End Function Public Sub UpdateTask() Try dc.SubmitChanges() Catch ex As Exception Throw ex End Try End Sub End class We are referring this application's Read More...
|
-
Hi All i am busy struggling with a linq function. i am trying to achieve the equivalant output that the following SQL gives: select b.documenttypename, b.url + '/' + a.documentpath as url, a.note, a.createddate, a.userdocumentid, a.documentpath from App_UsersDocuments a join DocumentType b on a.DocumentTypeID = b.DocumentTypeID where b.isSystemType = 1 and a.UserID = @UserID my linq function is as follows: Public Function GetUserSystemDocumentsDetail(ByVal userid As Guid) As IList Dim dd = (From Read More...
|
-
Hi All, I am new to LINQ . Here i am getting one problem while using query results more than once in my code. Dim col = From obj In db.MyStoredProc( ) _ Select obj.TextField, obj.ValueField Call PopulateComboBox(DropDownlist1, col, " TextField " , " ValueField " ) Call PopulateComboBox(DropDownList2, col, " TextField " , " ValueField " ) While executing this code i am getting error that " The query results cannot be enumerated more than once." Can anyone advise me on this ,how can i use one query Read More...
|
-
Hello, I'm creating a a project that will have about many different windows forms, all connected to the same database. I have a doubt tho, for now I have created a single datacontext, that is the exact copy of the database, with all his tables (they are about 50) so everytime that I create a new form I simply declare Private db as new datacontext would it be better to create several smaller datacontext files (with only the tables that I need to use in every specific form) and declare the right datacontext Read More...
|
-
How do I define a date so I can fetch it using Linq? I have no problem accessing the database or reading text and integer fields, but it balks on Dates. Leon Read More...
|
-
Hi there I'm using the following method to retrieve a collection of departments. I wanted to add an extra department (called "All") since it doesn't exist in the database. It works, but I'm sure there's a better way to do this in LINQ : Code Snippet public object SelectDepartments ( ) { var departments = from depts in tables. Department orderby depts. lblDepartment select new { depts. idDepartment , depts. lblDepartment } ; var allDepartments = new { idDepartment = 0 , lblDepartment = "All" } ; var Read More...
|
-
Hi, my select query returned IEnumerable>>. Is there any better way walking through 'a then foreach (var As in qResult) foreach (var Bs in As) foreach (var B in Bs) do work with B ? I mean for example some extension method like "Flatten" which would return just IEnumerable and traverse all nested IEnumerables available... Or do I build the query wrong ( from ... select from ... select from ... select )? Is there any syntax which would result in flat IEnumerable instead? Thanks! Jan Read More...
|
|
|
|