|
|
March 2008 - Posts
-
Can anyone tell me under what sort of circumstances do we need to write our own custom LINQ-SQL query provider? Cheers William Read More...
|
-
I created a dbml for linqdatasource. I have a stored procedure with dynamical sql. create procedure proc1 as ..... @sql = 'select '.... -- a dynamical sql exec(@sql) However, after drag the stored procedure to dbml. The return type of the stored procedure is just a integer instead of the return dataset. Anyway to get the return dataset using dbml? Read More...
|
-
Hello, I m using typed data adapter with ASP.NET 2.0 before. For each datarow we have a RowState (DataRowState.Modified, DataRowState.Added, etc.) which is handy to indicate which row is updated. Do we have similar thing in Linq or some alternate way to archieve that? Cheers, Elton Read More...
|
-
Hi all, I am reading a book about LINQ to XML and there is an example written in C# that I haven't been able to rewrite in VB.NET. Here is the query in C# xDocument.Element("BookParticipants"). Elements("BookParticipant"). Where(e => ((string)e.Element("FirstName")) == "Ewan"). Single().AddBeforeSelf( new XElement("BookParticipant", new XAttribute("type", "Technical Reviewer"), new XElement("FirstName", "Fabio"), new XElement("LastName", "Ferracchiati"))); The problem is around the where clause. Read More...
|
-
dears, how i can use the datacontext log property to get resule like that Code Snippet SELECT [t1].[OrderID], [t1].[CustomerID], [t1].[EmployeeID], [t1].[OrderDate], [t1].[RequiredDate], [t1].[ShippedDate], [t1].[ShipVia], [t1].[Freight], [t1].[ShipName], [t1].[ShipAddress], [t1].[ShipCity], [t1].[ShipRegion], [t1].[ShipPostalCode], [t1].[ShipCountry] FROM [dbo].[Customers] AS [t0], [dbo].[Orders] AS [t1] WHERE ([t0].[Country] = @p0) AND ([t0].[Region] = @p1) AND ([t1].[CustomerID] = [t0].[CustomerID]) Read More...
|
-
I am trying to figure out how to do exception handling when using LINQ. Currently I have a business class that calls into a web service that returns xml. I use LINQ to then construct business objects that are returned to my web ui. However I'm finding that, for example, when the xml is malformed coming back from the web service, that the error only gets thrown when I data bind on my web ui. I'm doing declarative databinding using a LINQ Data source. The only way around this because of LINQ delayed Read More...
|
-
Hello , please at this sample : Employee [] employees = Employee .GetEmployeesArray(); EmployeeOptionEntry [] empOptions = EmployeeOptionEntry .GetEmployeeOptionEntries(); var employeeOptions = employees.Join( empOptions, // inner sequence e => e.id, // outerKeySelector o => o.id, // innerKeySelector (e, o) => new // resultSelector { id = e.id, name = string .Format( "{0} {1}" , e.firstName, e.lastName), options = o.optionsCount }); when I see the parameter of " Join " Method , the first parameter Read More...
|
-
Hi, I've just started work on a new LINQ project in VB, having completed a recent one successfully. In my previous project, LINQ was working fine - as an example:- Dim Member = From a In DB . Persons If Member . Count <> 1 Then ... ... If I mouse over the word "Member" in the IDE, it reports it is of type System.Linq.IQueryable(Of Person). On my new project, I've done exactly the same thing, but this time when I mouse over "Member" it tells me it's of type "object" and there is no intellisense on Read More...
|
-
I have some code that looks like the following ParameterExpression param = Expression .Parameter( typeof ( Customer ), "c" ); Expression right = Expression .Constant( "MA" ); Expression left = Expression .Property(param, typeof ( Customer ).GetProperty( "State" )); Expression filter = Expression .Equal(left, right); Expression Func Customer , bool >> predicate = Expression .Lambda Func Customer , bool >>(filter, param); query = query.Where(predicate); This works find and generates SQL that basically Read More...
|
-
Can someone provide me a line of code that works for getting all the selected checkboxes in a checkboxlist? I'm trying var items= from item = cbList.Items where item.Selected == true select item; but I'm having no luck. Compiler is complaining that it can't find an implementation of the query pattern for cbList.Items. What am I doing wrong? thanks! Read More...
|
-
Hi all I've asked this question over at the Asp.Net forums but to no avail - I'm hoping someone can help me over here. I'm having terrible trouble trying to get the LINQ Dynamic Query Library ( as discussed in Scott Gu's blog ) to work in anything other than a web project, where there also exists a Data Context in the same project. So, I've got my website, and class library which contains the .dbml file and the dynamic query code file. When I try an compile this class library, I get errors such as: Read More...
|
-
Is there a way to disambiguate between two extension methods having the same signature and still invoke the method using the extension method syntax? Thanks. Read More...
|
-
Let's say I have a Person class with properties of Name, Address, ... and a custom collection People which is essentially a Generic.List(Of Person). I am using an xml document to store and retrieve the People collection. How do execute a SQL string that is created by the user against my business objects and return it as a DataSet? e.g. "SELECT Person.Name FROM Person WHERE Person.Name='John Doe'" Any direction or advice would be greatly appreciated. Of course my application is not as trivial as outlined Read More...
|
-
Hi, i am upgrading from classic ASP & vb6 to dotnet , i am started learning on my own with Xlinq which sounds cool, i am able to run the query and get the result from single XML file. but i have case where need to query a master detail relation from two XML files one information is like master and another is like detail. now i dont knew how to query using joins Xlinq? any ideas or do i need to change master detail relation. Thanks Read More...
|
-
I have a class today called Filter which can store some variable set of filtering criteria that I need applied, for example, it can store BrokerId In (100, 101) and ProductGroup In (1, 2, 3). I have made a post in the past about how to accomplish this in Linq located here http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3080473&SiteID=1 , but didn't recieve any responses about this. I was doing some more work and investigation on how to do this and come up with something that I think should Read More...
|
-
I am using Visual Web Developer 2008 with .Net framework 3.5 and SQL Server 2005. Here is my error message. Expression of type 'System.Data.Linq.Table(Of Department)' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider I have read many post, and all of them say to add references and imports. I made this post http://forums.asp.net/t/1239907.aspx on the ASP.NET forums and was advised to come here. Here are my imports for the BatchTrack.dbml Read More...
|
-
Hey there. How can i clone an element of a xml? Let me explaing better. Code Snippet I want add a new element that is a exact copy of and all of its childs. How can i achieve this with LINQ? Kind regards Read More...
|
-
I understand how to create a new LINQ to SQL dbml class by dragging/dropping tables, sproc's, etc from the Server Explorer onto the class.... but I am confused about how to keep it updated. Most people seem to say to simply re-create it by deleting all the tables, etc off - and dragging them back again (in the case of, for example, a database change).. One of the main reasons I began looking at LINQ was for the ability to effectively access data on vendor-supplied databases (basically ones that I Read More...
|
-
I have managed to build the following LinQ expresion: Dim LinesTotal = _ From rat In db.TAXRATEs _ Group Join inv In db.INVLINEs On rat.TID Equals inv.LPRDNO _ Into rateinv = Group , _ Total = Sum(inv.LEXTN) _ Select rat.TDESC, Total This all works fine. But I am unable to insert the Where clause, I think is should look like this : Where(inv.LTYPE = 2 And inv.LINVNO = invno) invno is a variable. Any help would be greatly appreciated. John Read More...
|
-
As everyone knows when we make an Association berween to entitySet in datacontex, in parent object we have all details objects and from each details object we have the parent object. Now my question is : if we make a class in the datacontext not set to a table in database, and make an Association between this object and a real object, in this case why datacontext does not generate an entity property of the real object in the class that i maked. excuse me for my bad english thanks inadvance Read More...
|
-
I am having a problem with refreshing an instanciated EntitySet with changes made elsewhere. I have tried refresh the parent object, or the child entityset property, or child entityset storage variable, with various refresh modes. I cannot seem to get the child EntitySet to add an inserted TEntity that it should recognize as belonging to the EntitySet by virtue of the foreign key association. My testing shows that once the parent object's child EntitySet has been instanciated, refreshing it has no Read More...
|
-
Hello ! I would like to know if it is possible to write your objects in the linq to sql disginer (dbml file) and than click somewhere and like magic it creates the table and the fields in sql-server? If not, could somebody put this one the wish-list? Thanks for any feedback! Regards, Fabianus Read More...
|
-
I have a lot of related tables in a SQL Server database. I simple would like to query a table for a specific item. If that item exists then retrieve the Identity Column and set a property (to be used to insert a new related row later). That part is fairly simple. I would like to take it a step further and if it does not exist insert a new record and then return the newly inserted record's Identity Column. The only way that I have been able to do this so far is with a number of queries which makes Read More...
|
-
Hello Experts, I am having following code . DataClassesDataContext dc = new DataClassesDataContext (); DataTable dt = new DataTable (); //Stored procedures dt=(DataTable) dc.proc_GetExistProductDetails(Request.QueryString[ "id" ]); Here i am not able to convert this to data table . I need this for maitaining some rows(result of stored procedures) temporarily before add to the database. how can i do? Is there any other way to maintain the results like list . how should i do? Give me a clear idea. Read More...
|
-
Hello, I have a parent object Customer, which gets cached in an ASP.NET application. Most of the data is read-only, which is perfect for this approach; however, one relationship (Orders) changes, and these changes can be caused by several people using the system. So, The Customer object, and the static data about the customer, is cached in the system. Initially I was caching the Orders as well, but this won't work any more because Orders will need to be updated immediately whenever there is a change Read More...
|
-
hi, i have an old web app that i would like to linq-ize. It features an on-the-fly generated sql search query to identify whole word matches. At the time the only way i could find do this was very inelegant (example below does not include checks for sql injection, literal apostrophe etc): Code Snippet whereFilter = String.Format("[{0}] = '{1}' OR [{0}] like '{1}[^a-z]%' or [{0}] like '%[^a-z]{1}' or [{0}] like '%[^a-z]{1}[^a-z]%'", searchColumn, keyword); it searches for an exact match, starts with Read More...
|
-
I wonder if someone has an example or an answer to why something like this doesn't work with a LINQquery lv.Items.SortDescriptions.Clear(); SortDescription sd = new SortDescription (sortBy, direction); lv.Items.SortDescriptions.Add(sd); lv.Items.Refresh(); lv is bound to a LINQ queryresult I found examples using other bindingsources and then I replaced those with LINQ (over SQL) and the listview doesn't show sorting. I understand that I can change the LINQ query to get a sorted result and then rebind Read More...
|
-
Does LINQ fully support sql server 2000, what are the features not supported can u please list them out. Read More...
|
-
Hi, I'd appreciate any comment about my issue (I simplified the problem by removing irrelevant details) : I am editing a list of rows from a single table on the client. I am removing a row and adding a row with the similar data. The request that is sent back to the server contains a deleted row and a new row. The server side uses a DataContext as follows: - for the row to delete context.TestTable.Attach(deleted_row); context.TestTable.DeleteOnSubmit(deleted_row); - for the row to insert context.Tests.InsertOnSubmit(new_row); Read More...
|
-
Imagine we have a table of staff (id, firstname, secondname) and to display them in a dropdownlist we use a linq datasource. Now if I want to display their fullname in the dropdownlist I try creating a partial class with a readonly property fullname which returns firstname plus a space plus secondname, then tell the linqdatasource to select the id and the fullname and bind to the dropdownlist. This works if the data is coming from sql 2005 but throws a "fullname is not a property of etc..." error Read More...
|
-
Hello. I'm ussing a query generated by linq: IQueryable ClientHoraire > horaire = from n in D.GetTable ClientHoraire >() where n.Code == Code select n; It's work fine with a test source based on SQL server, but my production database is under an AS400. I use ODBC to connect, and the driver does not supper bracket "[". {SELECT [t0].[ATBWCD] AS [Code], [t0].[ATAJHM] AS [Heure1Debut], [t0].[ATAKHM] AS [Heure1Fin], [t0].[ATALHM] AS [Heure2Debut], [t0].[ATAMHM] AS [Heure2Fin], [t0].[ATZFTU] AS [FermetureLundi], Read More...
|
-
Hi all, I do somethink like: MyTable _table = new MyTable; _table.BornDate = new DateTime(1988, 9, 4); // yyyy , mm , dd _database.MyTable.InsertOnSubmit(_table); _database.SubmitChanges(); Compilation okay, but code throws an exception - SqlDateTime overflow, date must be between 1/1/1753 .................... Debug fails on SubmitChanges(); Thanks Read More...
|
-
Hi, I need to create a new instance of a class that I created from a result of a linq query: Public Function GetClientById( ByVal clId As Long ) As List( Of ClientDetails) Dim dc As New CAATm_TempDataContext Dim q = From cl In dc.Clients Where cl.ClientId = clId _ Join ci In dc.ClientIps On cl.ClientId Equals ci.ClientId _ Join ca In dc.ClientAuthKeys On cl.ClientId Equals ca.ClientId _ Select New ClientDetails(cl.ClientId, cl.flgCcIS, cl.flgCbIS, cl.UserAgent, cl.ECMAVersion, cl.ECMAEnabled, _ cl.FlashPlugin, Read More...
|
-
Hello Experts, I have following code to display data in dropdownlist and displayed successfully, DataClassesDataContext dc = new DataClassesDataContext (); CustomerNameDropDownList.DataSource = dc.mCustomers; CustomerNameDropDownList.DataTextField = "CustomerName" ; CustomerNameDropDownList.DataValueField = "CustomerId" ; CustomerNameDropDownList.DataBind(); now i can display all customer's name in dropdown list. I just want to append the first index value of dropdownlist as - -Select customer name Read More...
|
-
Hey folks. I have two tables. The parent has a identity, and a varchar(30) column entitled "Code". The child entity has a relationship with the parent through the "Code" column. Through triggers and stored procedures, the "code" column gets converted into a combination of a static prefix, and the identity value. The "code" column is indexed(unique) and is not nullable. When I drag the tables into the LINQ Designer, the Association is shown graphically. When I compile my LINQ project, the parent entity Read More...
|
-
How would I add a "Order By" to this script. I was not able to get it to work on my own Public Shared Function GetTrackList() As List( Of TrackDDL) Dim ret = ( From t In MyCTXHelper.ctx.RangeTrackSIVinyls Where t.trackId > 0 _ Select New TrackDDL With {.trackId = t.trackId _ , .trackName = t.Track.trackName} Distinct ) Return ret.ToList End Function Thanks Read More...
|
-
public IEnumerable SubmittedOrderDocumentView > SubOrderDocView() { myVPCDataContext db = new myVPCDataContext (); IEnumerable SubmittedOrderDocumentView > docs = ( from d in db.SubmittedOrderDocumentViews where d.status == 29 orderby d.friendlyID select d).ToList(); The above has a csst issue and this is what I can't gget to work below??? //new { ID = d.friendlyID, docXML = d.simpleDocumentXML } into UnReleased // select UnReleased; //select d ; //new { ID = d.friendlyID, docXML = d.simpleDocumentXML Read More...
|
-
I have the following situation. I have a handful of different table that I call filter tables. Here is a simple version of the tables BaseValuesMatrixMain ShipToId PrdId BrokerId SizeId BaseValuesMatrixAnother ShipToId PrdId BrokerId SizeId PackageGroupId Now I know these tables look very similar and for the most part all of the filter tables do look very similar, sometime there might be a few extra or missing columns. What these tables contain is all of the distinct combinations of dimensions from Read More...
|
-
I drag two tables onto the designer surface with a simple one-to-many relationship. I create an association between the two tables and ensure that the Child Propery property of the association is set to 'true'. But....when trying to do a very simple linq query, intellisense is not providing the ChildProperty collection. What kind of scenarios can cause this? I've tried adding FK's in the DB. I've created and recreated the scenario MANY times. Have I missed a simple property somewhere that turns this Read More...
|
-
Hey Folks. I have a two-part Master/Detail Table where the child Table actually has multiple parents. Something along the lines of this: Child Table: Transactions: [ code, partNumber, quantity, etc, etc] PurchasingTransaction [ code, creator, receiver, dateCreated, etc, etc] ReceivingTransaction [ code, creator, stubNumber, dateReceived, receivingClerk, etc...] So that I have one child table that contains references to multiple parent tables. This is a requirement of the customer. To implement this Read More...
|
-
Say you have 2 tables: Items and UnknownItems, with identical fields. So I make a class such as Code Snippet [Table(Name = "Items")] class Item { //All properly mapped fields } Now, if I wanted to use the same class to map to my UnknownItems table, is there a way to do that? This would make things easier when moving fields from table to table, and I would not have to convert from one object type to another. It would also make my code more consistent since I would use the same Item class throughout Read More...
|
-
I have two queries: DECLARE @p0 AS VarChar(2) SET @p0 = 'WA' DECLARE @p1 AS DateTime SET @p1 = '12/31/2006 12:00:00 AM' DECLARE @p2 AS DateTime SET @p2 = '12/1/2006 12:00:00 AM' -- query 1 SELECT [t0].[CLM_ID] AS [ClaimId], [t0].[CLM_ENR_ID] AS [EnrolleeId] FROM [dbo].[Claim_Master] AS [t0] WHERE ([t0].[CLM_ST_Of_Jurisdiction] = @p0) AND (([t0].[CLM_Added]) = @p2) -- query 2 SELECT [t0].[CLM_ID] AS [ClaimId], [t0].[CLM_ENR_ID] AS [EnrolleeId] FROM [dbo].[Claim_Master] AS [t0] WHERE ([t0].[CLM_ST_Of_Jurisdiction] Read More...
|
-
Hi, I'm trying to insert into an address table, a company table and join the two in a company_address table. IT doesn't work, sometimes it complains about foreign keys other times it just doens't insert and no error is shown. Company company = new Company () { Name = c.Company, PortalID = 55, Description = "Some text" , CategoryID = 7 //General }; Address a = new Address () { Road = c.Address2, BuildingName = c.Address1, Area = c.Area, Town = c.Town1, PostCode = c.Postcode, CountryID = 225, County Read More...
|
-
I have followed the following steps: Installed the LINQ to XSD download Go into VS2008 ->New Project ->Linq To XSD Console Application ->Create a new XmlSchema ->Open it up in the editor ->Paste in a valid XSD ->Close, save ->Select XSD from Solution Explorer (note that no XSX is showing up as a sub item yet) ->Change Build Action to 'LinqToXsdSchema' ->Save ->Build / F6 ->no XSX generated, no code generated ->exit vs2008, reboot machine, etc, still can't get anything to generate Anybody have any Read More...
|
-
I get an error on my select , error from IDE next: Error 1 Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?) C:\Temp\LinqDataService\LinqDataService\Source\Classes\SubOrderDoc.cs 41 56 LinqDataService Simple class here: public IEnumerable SubOrderDocView(int Stat) { myVPCDataContext db = new myVPCDataContext(); IEnumerable docs = from d in db.SubmittedOrderDocumentViews where d.status == Stat Read More...
|
-
How do I reload a table in a DataContext? I have the DataGridView bound to the DataContext table through the BindingSource and I want to allow the user to cancel all changes and reload the original data from the database. As oposite to SubmitChanges. Read More...
|
-
Here is my SP. /********************************************************************************************************* * Type : Procedure * Name : spGetCourseEmailList * Input Parameters : @Code1 * Output Parameters : None * Purpose : This stored procedure gets the Members for a particular Chapter Event the cached items. **********************************************************************************************************/ CREATE PROCEDURE [dbo].[spGetCourseEmailList] ( @Code1 char(9) ) AS Read More...
|
-
I'm looking for orphaned files in a directory based on a sql query. We auto create thumbnails if the file is an image. On my sql table, path = the file, optpath = the thumbnail (or null). Based on that, I need an OR statement on the query where the filename = path or optpath, and I need to return all results that don't match. I have this working but it's not very efficient since it joins to the attachment table twice and that table is close to 1 million rows, so I would like to join to it once. //working Read More...
|
-
I have bunch of entities fetched out by one thread, then those entities are grouped. Each group is passed to a different thread to process it. Now because DataContext is not thread save I get a bunch of weird errors on deferred loading and other LINQ stuff. It's clear to me that each thread must have it's own DataContext, but the question is how do i pass fetched out entities to thread's DataContext? Read More...
|
-
I code these: public static IQueryable And(this IQueryable source, Expression> predicate) { MethodCallExpression methodCallExpr = ((MethodCallExpression)source.Expression); if (methodCallExpr.Arguments.Count != 2) { return source; } UnaryExpression unaryExpr = (UnaryExpression)methodCallExpr.Arguments[1]; ConstantExpression constantExpr = (ConstantExpression)methodCallExpr.Arguments[0]; IQueryable newSource = (IQueryable)constantExpr.Value; Expression> funcExpr1 = (Expression>)unaryExpr.Operand; Read More...
|
-
hi, in this function I want to return the full "row" of a table. Code Snippet Public Shared Function GetUserDetails( ByVal UserName As String ) As DataContext_MyDirectory.TPeople Dim dc As New DataContext_MyDirectory.MyBlabla Dim var = From f In dc.TPeople _ Where f.Sn + " " + f.Givenname + " (" + f.Uid + ")" = UserName _ Select f Return var End Function this results in the following error: Unable to cast object of type 'System.Data.Linq.DataQuery`1[VB$AnonymousType_2`1[DataContext_MyDirectory.TPeople]]' Read More...
|
-
I need help transforming name value collection into collection of annonymous types. Is it even possible? For example if I have NameValueCollection like this Specialized.NameValueCollection c = new Specialized.NameValueCollection; d.Add("prop1", "1,2,3,4,5"); d.Add("prop2","a,b,c,d,e,f"); I need to create a collection of anonymous types where key's would become proerties (prop1, prop2) and values would be split on ",". So in this case I would have collection of 5 anlnymous types with properties prop1, Read More...
|
-
Hi, I'm starting to look at LINQ and I understand the basics but can't figure out how to use LINQ to populate a custom object. I have a custom class that represents a standard ADO.Net DataSet. For simplicity this example will only contain a tables collection. My classes are as follows. public class testDataSet { public testDataSet() { Tables = new List testTable >(); } public testDataSet( List testTable > tables) { this .Tables = tables; } public List testTable > Tables; } public class testTable Read More...
|
-
CoDe Magazine published an article on XML Tools. It covers a wide range of topics: Editing XML files, Schema cache and catalogs, Performance and working with large files, XSLT debugging, and Extending XML Tools Enjoy! Read More...
|
-
Hello, I was wondering if anyone knows if someone has developed a LINQ query tool, where you could query and see the results in an editor like SQL Server Management Studio. Theoretically it's possible, and I was wondering if someone has figured out a way to do it. Thanks. Read More...
|
-
Some of the opponents of Open XML have stated that because a final draft of the specification with all approved changes is not available, National Standards Bodies should decide to vote Disapprove. This is pure FUD, and they know it. The final draft of the specification can't be made available until after the vote reconsideration period, per ISO/IEC JTC1 rules . Furthermore, this was announced at the Ballot Resolution Meeting. Participants were instructed that national bodies need to base their decision Read More...
|
-
With the release of LINQ, the ASP.NET MVC Preview, and Server 2008 with IIS7, I've finally gotten over the web-developer's block that has prevented me from porting my old website off of Zope. So I'll be posting to my revised website from now on. It'll let me play around more with the new toys, including Silverlight. Read More...
|
-
I don't know how to use' like [a-g]%' syntax in linq, I know about startswith() but I want to search a list of name which start from A or b throght g please help Read More...
|
-
Any pointers to article on how to write generic code on LINQ, so that underlying data source can be either object/database/enity/xml? I want to have code which uses LINQ to fetch data, without having any knowledge where that data is persisted. It can be done through IQuerable. any articles on best pracitces/recommendation for that Read More...
|
-
|
Hi all. I have a project in which I am using the LINQ to SQL mapping. Originally, when I added classes to the .dbml designer, all the partial methods for the class, such as OnCreated(), OnLoaded(), etc. were being created. Then, for whatever reason, they stopped being generated. What interesting is all of the "earlier" classes I created still have the partial methods. Everything at the top of the autogenerated code file has them. Bu | |
|