|
|
October 2007 - Posts
-
I am new to LINQ and would like to know when and where to use LINQ in your architecture and design. Is it meant to replace the data access layer? or is it just meant to do queries over offline data in the middle tier? does anyone know the best practices of when and where exactly to use LINQ? Read More...
|
-
I have the following LINQ query PurchaseOrder purchaseOrder = transactionDb.PurchaseOrders.Single(p => p.TrackingNumber == orderNumber); var q = from p in db.Payments where new Guid (p.OrderId) == purchaseOrder.OrderGroupId select p; The reason for the new Guid is that in the database on the Payment table the column OrderId is a string (varchar) and not a Guid. When I look at the log I see that the following SQL is created: SELECT [t0].[PaymentID], [t0].[PaymentTypeId], [t0].[OrderId], [t0].[BillingAddressId], Read More...
|
-
Hi I've just noticed that when I use DataLoadOptions to eager load part of an object graph from a Sql Server 2000 database, I get an individual query for every single related row, plus one for the top level objects. The same code run against a 2005 database runs as expected, i.e. only one database query. Looking at the SQL that's generated for 2005, it uses a left outer join to pull back all the data in a single query. Looking at the BuildQuery method in the SqlProvider class, when the provider is Read More...
|
-
If a table contains identity field or caculated field, the Entity class attributes will be related to AutoSync=AutoSync.OnInsert AutoSync=AutoSync.Always and so on. But some time I do not need the Sync when I insert / update the table. I want to minimize the data transformed between server and database. i.e. I insert a new row in to the table, and I need the @@identity, so I should trun on the AutoSync And then I insert 1000 new rows in to the table, and I do not care about the @@identity, so I want Read More...
|
-
Hi, I'm successfully using SqlMetal Beta 2 ... until I try to include user defined fuctions in the SQL Server 2005 DB with the /function flag (see below). These functions work fine with "classical SQL queries" from C#. The error below tells me that there is a needle somewhere in a huge hay stack: there are a myriad system functions and several user defined functions. Is there any way to get more precise information from SqlMetal as to the source of the problem, or any hint as to what may be causing Read More...
|
-
Hello First of all, sorry that the title is not more meaningfull. Couldn't think of anything better. I'm just starting out with LINQ and I already ran into a problem. Checked all possible things and didn't find the problem. Probably looked over it again. Hope someone of you can point me to my mistake. I'm trying to get some info from a RSS feed. I tried connecting to it online and also took it offline and placed it in a XML file on my hard disk, without any result. Here is the RSS location i'm using. Read More...
|
-
Hi, I have come into a situation where my query throws an exception "The null value cannot be assigned to a member with type System.Decimal which is a non-nullable value type." I have 2 tables Customer and Account The customer table has record but no record exists for the account table so when I do the following in my projection var sumTotalCredit= db.Account.Where(a=>a.CustomerID==3).Select(o => o.CreditLeft).Sum(); it throws an exception as mentioned above. How do you handle this kind of situation? Read More...
|
-
I want to adjust the query sent to the SQL server with LINQ to include "WITH(NOLOCK)" so that table is not locked during the query. I realize that this is not applicable to all data sources and is most likely specific to just SQL server but just the same I would like to be able to specify this query "hint". Can it be done? Thank you. Kevin Read More...
|
-
Is there a way for SQLMetal to generate table classes without it specifying the access modifier? I typically create additional partial classes for each table class and I'd like for the partial class to have the ability to provide the access level of the class. Read More...
|
-
I might miss the obvious and hopefully somebody could give me a quick explanation. Goal Populate a customer object with details from multiple tables. Tables (not all of them have foreign key constraints) Customer Order Account Shop etc..... Code Block //Read Customer var cust=from c Customer Join o order on c.CustomerID equals c.CustomerID Join a Account on c.CustomerID equals a.CustomerID join s shop on o.OrderId equals s.OrderiD where c.CustomerID=1 Select new { c.CustomerId,c.Name,c.Surname, o.OrderName,o.OrderTotal Read More...
|
-
Most simple D-LINQ operations work fine against SQL Server 2000 - however, some don't. For instance, paging over non-trivial queries. Is there an official statement about what is and isn't supported? My question isn't really about this *specific* query, but more on the "things to avoid"... Example shown in post here: http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/msg/377a7b0347ab7161 Marc Read More...
|
-
I have an application that was written using Visual Studio 2008 that uses basic LINQ constructs. The only problem is that my client wants to use their Windows 2000 Server to host the application. What would I need to do to run this application using them May CTP? I know that a lot of the name spaces changed, but other than that, did things stay the same, pretty much? Jim Read More...
|
-
I've been testing some Linq2Sql query's and I came over what seems to be a bug with some extensions. Code Block var blogQuery = from b in db.Blogs select b; var blogs = blogQuery.ToList().Take(5); The above code is fine, and in my test it takes around 150ms to execute. Code Block var blogQuery = from b in db.Blogs select b; var blogs = blogQuery.Take(5).ToList(); This code however seems to take take around 200ms to execute, and with more data in db.Blogs is feels like it runs the linq query twice. Read More...
|
-
With my First view on LINQ, i understand that we will be able to query a database through the .net C# or VB statements.. In this case of the queries written in code, will I be able to get the same level of query performance that i get with the similar query using my SQL Stored procedure?? The concern is, will we still be able to use the Query Optimization stuffs from the SQL Server? Read More...
|
-
I have a new project and I would like to use LINQ To SQL as a data access layer but I am confuse as to how to structure the entity and its manager. Currently, I am envisioning it's something like the data mapper pattern as seen here http://martinfowler.com/eaaCatalog/dataMapper.html . Do you have any recommendations or sample codes somewhere that I can take a look. Thank you Read More...
|
-
How do you specify which field to use for the result of a join when the sources have the same structure? For example, ProductList is a class which has two properties ProductId (int) and ProductName (string). There is a master reference which ties ProductIds to ProductNames. I want to use the master reference to add the correct ProductId to a customer's ProductList which only has ProductNames. var masterProductListReference = ...[Has both ProductName & ProductId]... var customerProductList = ...[Has Read More...
|
-
I am having a problem with databinding. Here is my goal: Provide a windows form that is databound to a linq class (Tasks) for inserting a new Task in the database. I have tried the following: 1) browse to the datasources view, find the Tasks entity, click the drop down to change its type to Detail instead of gridview 2) Drag the Task entity to the form. This creates a labels and text boxes for all the entities, and creates a TaskBindingSource. 3) In code, set the following Code Block TaskBindingSource.DataSource Read More...
|
-
Hi all, In sql is very common to have queries that check for nulls or have case statement. if the below cannot be done in linqToSql what is the workaround? Suppose you have a select statement and needs to return CustomerPassword,myValue ISNULL (userTable.Password, emailTable.AgtPassword) AS customerPassword CASE WHEN UserTable.UseID IS NOT NULL THEN 1 ELSE 0 END MyValue Really really struggling on this Thanks a lot Read More...
|
-
I have two tables from two different ACCESS databases. The dat & schema are identical. Basically, one is for editing and the other is for public viewing. I want to compare the two tables and know if there are any changes present. LINQ should allow this with the .Except command. The thing is that I can not get it to work. If I test the datatable against itself it comes back null (which makes sense - no differences). If I test one database against the other I get all records reported back as different Read More...
|
-
Hi cannot seeem to be able to write a bit of LinqTo Sql to generate this kind of join "Join Orders O on C.CustomerID= O.CustomerID and OD.ID=O.ID" Even though the below sql might not make sense I just want to give you an idea or what I am trying to generate. Select * from Customers C Join OrderDetails OD on C.customerID=OD.CustomerID Join Orders O on C.CustomerID= O.CustomerID and OD.ID=O.ID where etc...... basically how do you write an inner join with an And Clause attached? thanks a lot Read More...
|
-
Sorry if anyone's thought of this before, or if I'm breaking any rules by posting this here, but I thought I'd share this little song parody with you all... Sing it to the tune of the overworld music from "The Legend of Zelda" of course - and thanks to the band Rabbit Hash for the "original" song! ;-) LINQ, it come to town It come to save your precious data SQL took it away, now the coders can't play But they will when LINQ save the day! HALLELUJAH! So LINQ, fill up your grid So you can load the Read More...
|
-
I have created a new Website project from VS2008 Beta 2. When I try to execute the project I get the following error message: Failed to access IIS metabase. Along with the error message further explaination: The process account used to run ASP.NET must have read access to the IIS metabase. (e.g. IIS://servername/W3SVC). For information on modifying metabase permissions, please see http://support.microsoft.com/?kbid=267904 . I downloaded the metaACL package and executed the following: metaACL "IIS:///W3SVC" Read More...
|
-
hello, has anyone out there good documentations about expression tree(s). did ms plan to update the msdn to give developers a hand ? it's very hard to parse the syntax tree to get informations needed (especially if you develop a complex linq provider). regards mattgo Read More...
|
-
I am new to Linq and Anonymous Types so please be kind. What is the best way to save the state of a query between posts so that I can sort and page using the DataGrid? For example, if I have a linq query like: Code Block Dim Results = From P In DC.Parties Where P.PartyName.StartsWith(_PartyName.Text.Trim) _ Order By P.PartyName _ Select P.PartyName, P.Division, P.CaseNumber, P.Atty, P.Atty1.AttyName, _ P.Main.DateFiled, P.Main.CaseType _ Take (1000) GridView1.DataSource = Results GridView1.DataBind() Read More...
|
-
A bit OT, but does anybody have a reference to the LINQ extension points? By this, I mean things like the Insert{Entity}({Entity}), Update{Entity}({Entity}), Delete{Entity}({Entity}) pattern of methods that LINQ picks up using reflection. I know the MSLinqToSQLGenerator tool outputs these as partial methods, but are there others that it doesn't advertise? Is there somewhere that lists these things? Marc Read More...
|
-
I am binding a linq query to a windows forms datagridview by setting the datasource to the linq query. When i do this in code, all of the columns appear in the gridview in alphabetical order by column. What is the best way to control the order of columns? Read More...
|
-
Hi I'm using LINQ to SQL from VS 2008 with SQL Server 2005 (dev edition - sp2) and developing a web application, doing my testing with VS internal web server. After 6-8 hours of developing, hitting the database quite alot, it suddenly becomes very unresponsive. I can fix it by restarting the SQL service, which leads me to believe there are unclosed/dead connection or LINQ to SQL is causeing problems. The queries I perform are pretty basic (select from one or more tables with some custom projection Read More...
|
-
Hi, Where can I find a latest version of LINQ To Amazon that will work with VS.Net 2008 Beta 2? Thanks Lennie De Villiers Read More...
|
-
i.e. a "save" SP has an optional, defaulted parameter: "@Batch_Size int = NULL OUTPUT" adding the function to the dbml correctly configures this as: "ref Nullable batch_Size" however, if you use the dbml designer to customize the update behavior, and don't specify anything for this mapping (since there is no suitable candidate column), then the generated code for the mapping uses: "default(System.Nullable)" as the value, which isn't "ref", so breaks at compile time (along with an overload method Read More...
|
-
Is there a simple way to get LINQ to pass additional args to an insert/update statement? Our tables have audit columns to record the last update (just who/when). Pre-LINQ, we did this by passing the "principal" name into an SP, and updating the columns at the database. We use the "trusted subsystem" model, so a trigger reading the connection's username is no use - it will show the service credentials, not the end-user's. With LINQ, I guess I need to either: * use default LINQ update (etc) methods, Read More...
|
-
Is it possible to use SQL-CLR udts for a property on a Linq to Sql class ? Read More...
|
-
To get an original entity item, I use: Code Block Order originalOrder = db.Orders.GetOriginalEntityState( currentOrder ); The above example returns originalOrder, but NOT originalOrder.OrderItems. How can I get originalOrder.OrderItems? Thanks! Read More...
|
-
I am a newb to the VS environment. I am trying to create an LINQ ASP.NET Web Site application, using the instructions located at: http://weblogs.asp.net/scottgu/archive/2006/05/14/Using-LINQ-wtih-ASP.NET-_2800_part-1_2900_.aspx . The screen shot shows a template "LINQ ASP.Net Web Site" however I do not see this template in my version of the Studio. I am running VS 2008 Beta2. The instructions talk about downloading the May CTP drop of LINQ, however this seems to be an additon for VS2005 not VS2008. Read More...
|
-
Here it is: http://www.albahari.com/linqquiz Tell me your scores! (or your criticisms of the test :) Joe Read More...
|
-
I am trying my first LINQ query and I am getting: TestCase 'M:BuySeasonsBrowse.MainWindow.transactionButton_Click(System.Object,System.Windows.RoutedEventArgs)' failed: Login failed for user ''. The user is not associated with a trusted SQL Server connection. System.Data.SqlClient.SqlException: Login failed for user ''. The user is not associated with a trusted SQL Server connection. at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection Read More...
|
-
I have several (hundreds) of Lucene.NET index databases, one for each day (yyyy-mm-dd folders). I want to implement LINQ over the indexes to do ad-hoc queries, treating the entire set of folders as a single historical database. Is this possible, if so, where do I start? Are there interfaces I can implement in my own classes to allow LINQ to traverse and query these indexes? Also, is it possible to use LINQ from within a Silverlight application? Thanks! Read More...
|
-
Quick question: Will the LINQ to SQL Debug Visualizer be part of the RTM or will it always be a seperate download? I am referring to the download that Scott Guthrie discusses here: http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx Thanks Read More...
|
-
I have installed Visual Studio 2008 Beta 2 and I have not been able to find SqlMetal.exe. Am I missing it somewhere or do I need to download it? Kevin Read More...
|
-
There is already so much fiction/scientific/medical/... literature in English so why doesn't everyone in the world just speak English? There are so many dialects and variations of English that one has to often understand. Why bother with another language at all? After all, the purpose of inter-human communication is nicely served by English. What is with all those crazy people who speak other languages - especially when they are related to English (say Indo-European group of languages). Sorry, I Read More...
|
-
I don't get this at all. You already have SQL syntax programmed into SQL server, You have SQL syntax programmed into other objects... yet to as you say "USE the power of SQL" you don't use .... SQL. Instead there is yet another syntax that is different. Not hugely different I agree, but different none the less. If you are going to be building something from scratch... why not just build it correctly the first time so that interoperability and the learning curve is completely minimal???? I appreciate Read More...
|
-
Hi How do i replicate the functionality of thw SQL in keyword using LINQ syntax i.e. select id from qwerty where id in (2,5,6,1) I imagined it to be like var a = from bugs in context.db where bugs.id in (2,5,6,1) select new Bug() {Id = bugs.id} but this does not work can anyone help? Regards Allan Read More...
|
-
Hi, Keeping it simple: A query returns two fields, int Sequence string Name Given a little mapping type public class Map { [ Column (Name = "Sequence" )] public string ID { get ; set ; } public string Name { get ; set ; } } Executing the query with context.ExecuteQuery(... The query does not retrieve values for the ID field unless it is named Sequence. I know that linq uses reflection to perform the mappings so no surprises here, but it also does not observe the ColumnAttribute. Is there a plan to Read More...
|
-
We are at the beginning of putting together a new application architecture based on LINQ. For current apps, we're using a multi-layered architecture: DAL = typed datasets, BL = own business entity classes, are loaded from datasets and persist into datasets, contains business rules & validation PL = uses BL classes only Now LINQ for SQL does generate entity classes out of tables. Are they thought to be a replacement for the DAL only, and should we continue to build our own BL classes? Or is it better Read More...
|
-
I've linked a gridview to my LinqDataSource. All is working fine. I've added a where paramter to the datasource for an ID field. Now what I want to do is set it up to load all records on the initial load. I can put in a parameter and serach fine. I just can't figure out if there is some type of wild card or something special to do for this. When using a SqlDataSource and stored procedure, I could do either a coalesce or write an if statement in the proc to return all if there is a certain parameter Read More...
|
-
I have a very simple query such as... Dim DB As New DataClassesDataContext Dim Results = From P In DB.Parties Where P.PartyName Like _Name.Text.Trim & "*" _ Order By P.PartyName _ Select P.PartyName, P.Division, P.CaseNumber GridView1.DataSource = Results GridView1.DataBind() Now, when I run this against a database of a few hundred thousand records it appears to run ok, but switch to a database of several million records and it takes about 20 seconds to run. When I look at the performance report Read More...
|
-
I found a problem today when using the LINQ to SQL generated code to call a stored procedure that has a numeric output parameter. For example, I have this sproc: ALTER PROCEDURE [TestProcedure] @nReturnValue numeric(16,12) output as begin set @nReturnValue = 1.234567 end I dragged the proc to the LINQ to SQL designer and it generated this: [Function(Name="dbo.TestProcedure")] public int TestProcedure([Parameter(DbType="Decimal")] ref System.Nullable nReturnValue) { IExecuteResult result = this.ExecuteMethodCall(this, Read More...
|
-
I really want to use LINQ for a current ASP.NET project but I'm getting stymied. I downloaded and installed .NET 3.5 which contains the LINQ assemblies (I believe); however, when I try to build the LINQ samples, VS.NET doesn't recognize them. Question about LINQ: Is this some kind of "experiment" or is this the future direction that Microsoft wants us to go for code to SQL interaction? Read More...
|
-
I have a parent table User, and a child table, User_Synonym, which has the user's name from an external system. (There's a third table, User_Synonym_Type, which is also a parent of User_Synonym, which gives me which external system the synonym's for.) Here's my delete code inside the User class. Code Block public void DeleteSynonym(string Name, string Value) { int cnt = User_Synonyms.Count; for (int idx = 0; idx { User_Synonym syn = User_Synonyms[idx]; if ((syn.User_Synonym_Type.User_Synonym_Type1 Read More...
|
-
Greetings All, I would like to pose a question to the LINQ community, though whether I would ever use this in production code, I do not know. I think its roots are more curiousity then necessity. How can I order by objects, that is how can I compare two instance of the same object and use internal logic for ordering. I am well aware that I can emulate the same process using the current form, but I can think of a couple cases where this may be useful as well as reduce clutter. A simple example of Read More...
|
-
I can't believe I'm running into problem. Has anybody run into this problem? I create a Northwind.dbml by dragging the Customer table onto the Linq to Sql designer surface. Click on the save button. Then I drag the GridView onto a Web Page. Going through the "New Data Source" option, I choose Linq, but when I get to the "Choose a Context Object" screen, my NorthwindDataContext doesn't display as a choice. I went as far as going to the properties of the desiger surface and giving a name to the Context Read More...
|
-
The problem is that the anonymous type cannot be used in a method call parameter, and when I use IEnumerable I lose my field names. I only see my IEnumerable interfaces. So, how do I get my field names back? Below is a clip from another site where I also posed this. Fijiwalano Shun: BrianMinister: I am trying to figure out how to marshal a ling query result and even work with the resultset in general. I have posted my questions as comments in the code below. At the moment, I am at a dead standstill Read More...
|
-
Hi Every Body, I've seen this question many times since I started using LINQ to SQL, the problem is, "Sometimes when you make a change in the entities in the designer and save, only the saved changes are in the dblm file, the designer does not regenerate the code after saving. Also there's no method to refresh the code or to force the designer to do it the time we want." The only method till now is to delete the entity classes and then define again, this also sometimes does not work either> I've Read More...
|
-
I get the following warning from SQL Metal: Warning 2 Unable to extract stored procedure 'dbo.GetStackedProcesses' from SqlServer. Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32). c:\Solutions\Temp\Paladin\Paladin.Logic\EXEC Paladin.Logic I've put in a conditional statement that says not to continue to process anything past 31 layers, but it doesn't seem to care... How can I over come this problem... OR Alternatively, is there an easier way with LINQ to extract Read More...
|
-
Hi All, I am very new to this LINQ stuff. i just started wandering around this thing.. I got Login faied exception when i try to connect the DB. The same thing is workin for me from other things execpt LINQ. i am using the same config settings... it throws an error when i trying to bind the query to the Binding source... This is the actual exception.. {"Cannot open database \"Northwind\" requested by the login. The login failed.\r\nLogin failed for user 'sa'."} It seems the code is straigt forward.. Read More...
|
-
Hi, I've been looking at this for several hours now, and can't find a solution. Hopeyou can help: I have a presenter class which sets the following Query on the view: Code Block var query = from c in db.Consultants select new { c.ConsultantId, c.Initials }; this .view.Consultants = query; Now I try to test the presenter in my unit tests and find out if the IQuerable returns the expected results: Code Block foreach ( var r in mockView.Consultants) { Assert .AreEqual(1, r.ConsultantId); Assert .AreEqual( Read More...
|
-
We've just started experementing with SqlMetal and love it... but today we came across a naming discrepency in the created dbml file that has raised some questions... It has to do with two tables that are linked by multiple Foreign Keys... so let's start with the table schema: dbo. Person ====== PersonId -PK -Identity ... ... dbo. Salutation ======== SalutationId -PK -Identity ... UsedByPersonId -INT -FK(Person) UsedForPersonId -INT -FK(Person) ... (Each Person can have mutiple Salutations. Each Read More...
|
-
In my .dbml file, I have a view and a table. I manually created an association from the view to the table, but the LINQ to SQL designer won't generate the EntitySet and EntityRef properties for this association. Anyone know why? Read More...
|
-
Hi, What events, if any, are fired after an entity has been added or removed? Thanks! Read More...
|
-
Is there a way to add your own methods and properties to entitysets? e.g. I have Customer.Orders and would like to add Customer.Orders.RemoveAll(). Thanks in advance! Read More...
|
-
We're working on a new app using LINQ to SQL and we ran into some interesting scenarios. This is a client/server app (we would like to use WCF but for various reasons we can't do that right now). Let's say that I have the following scenario: 1) User loads up an object from the database... let's call it a Widget 2) In the UI, the user makes some changes to the Widget 3) The user clicks a Save button, and the UI calls some method on the business layer to save the Widget 4) Before we save the Widget Read More...
| |
|