|
|
August 2007 - Posts
-
Hi, I was able to do two-way binding of simple SQL data types (int, varchar, datetime, etc) into a WPF textbox control using ADO.NET EDM Beta 2. My question is whether it's possible to do the same for SQL XML data type. My purpose is to bind XML attributes or nodes inside an xml data type into a WPF control using either ADO.NET EDM or LINQ. I assume this might require some combination of XQuery and ADO.NET EDM/LINQ queries. A possible solution might be a two-step process: 1. Load the xml data type Read More...
|
-
I was wondering whether LINQ to SQL supports the new HierarchyID datatype in SQL Server 2008? I bet there's a lot of developers out there is looking forward to replace their adjancency lists (parent / childs) and nested set models with the new hierarchical identifier. Thanks in advance. Read More...
|
-
Anyone run into this problem before? I am passing a SQL connection string when creating my data context object but the data context is appending Integrated Security=SSPI when I am not using integrated security, we are using SQL Native. Here is my string: server=qaserver;database=absTester;uid=sa;pwd=12345;Max Pool Size=125; Min Pool Size=5; Here is the datacontext.connection.connectionstring value: server=qaserver;database=absTester;uid=sa;pwd=12345;max pool size=125;min pool size=5;Integrated Security=SSPI Read More...
|
-
Is there currently any way to resolve the Linq to SQL type impedance mismatch as explained in the last comment of the following help article? ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/wd_linqadonet/html/0a90c33f-7ed7-4501-ad5f-6224c5da8e9b.htm The problem occurs when running Linq queries against a non-Unicode DB. Linq produces Unicode parameter descriptions in it's SQL, which results in the DB Engine missing the opportunity to employ indexes when evaluating queries. I have solved the problem using Read More...
|
-
Hi again If I try to run the following: Dim res14 = dc.Agents.Aggregate(0, Function (sofar As Integer , a As Agent) sofar + a.Name.Length) I get a "NotSupportedError: The query operator 'Aggregate' is not supported" error. Hmm, did you forget something here, or is it intentional that the general aggregation operator cannot translate into SQL? For my part, I would expect this one to be the most difficult to map to SQL in anycase, so it whould be understandable. A answer of the form "No, we have no Read More...
|
-
I have this function: Code Snippet public IQueryable Debtor > GetDebtors( string firstName, bool firstNameIsLike, string lastName, bool lastNameIsLike, string city, bool cityIsLike) { var deb = from o in db.Debtors select o; return deb; } What I want is that a string is filled the query is filtered on this. Also it is possible that I have to have an exact match or a like on that column. In SQL Query it was very simple, with some If statements. What I need is something like this: Code Snippet string Read More...
|
-
When I try to run the following query Dim res14 = From a In dc.Agents _ Where ( From agt In dc.Agents Where agt.ID = 10).Contains(a) I get the error message: NotSupportedException: Queries with local collections are not supported This I think is an appropriate error message! If I rewrite it into: Dim res14 = From a In dc.Agents _ Where New Agent() {( From agt In dc.Agents Where agt.ID = 10).First}.Contains(a) I get the error message NotSupportedExcepteion: Constructed arrays are only supported for Read More...
|
-
I'm using Linq for Sql Server in a web application. Everything's working fine when I use Visual Studio Development Server but I have the following error when I use IIS: Login failed for user ''. The user is not associated with a trusted SQL Server connection. Why is there a difference? What setting should I change? (I use , my IIS is configured with "Integrated Windows Authentication", I have the same error with Anonymous access) Read More...
|
-
Mathew Charles of the LINQ to SQL team has revealed our shameful secret: http://blogs.msdn.com/digital_ruminations/archive/2007/08/30/devs-writing-haiku.aspx Read More...
|
-
Great product! However, I'm a VB.NET developer and would like to see a VB version. Are there any plans in the works for that? Baron Read More...
|
-
Simple question--how do I add a property to a LINQ table object without breaking its ability to bind? If I just add a new property to the CS code, when I try to populate the object from the DB I get a Bind error. In this case, I'm trying to add a property called "ID" onto a table called "Project". {"Binding error : Member 'Fsw.BusinessObject.Dlinq.Project.ID' is not a mapped member of 'Fsw.BusinessObject.Dlinq.Project'."} at System.Data.Linq.SqlClient.SqlBinder.Visitor.AccessMember(SqlMember m, SqlExpression Read More...
|
-
I am transforming one of my existing projects to start using LINQ. I am facing syntax error when I try to use LINQ query inside an ASP.NET page. But when I use the same query in a seperate class (like Business Layer), it runs fine. The syntax error is all over the place for that query, so I cant understand. Could be something very little. Help me out please!!! //Data fetched from LINQ data layer stored procedure call and returned from Business Layer to the UI public List GetRatingsResult > GetRatings( Read More...
|
-
Hi, I am puzzeled what LINQ-Team thinks i should use to solve this scenarios: 1. I have a Web App that runs on multiple servers. Here is some pseudo code: foundUser = (select aUser in db.users by cookie_id).First() (1) if (aUser == null) db.users.Add(new User(...CookieID=cookie_id ... )); (2) db.SubmitChanges(); So assume that two web servers A and B are running this same code. Web Server A has executed statement (1) Web Server B executes db.SubmitChanges() later on Web Server A continues in (2) Read More...
|
-
Hi, I am using LINQ with BETA2. I have added a new row in table using ADD on Datacontext, Now I wanted to get the identity key back for further operation. Is there any way to get Identity key/primary key back from the database? Thanks Hasmukh Read More...
|
-
when submitting changes to a table with a computed column. Why is linq to sql code trying to update a computed column? Read More...
|
-
As I'm moving forward learning Linq, my next step is to formulate the workflow when developing a new database application using Linq and SQL2005. Normally, I design my database schema before coding my application, as close as I can get to my specifications. But no matter how close I/you get, there are always changes while developing application. Since this schema was designed in SQL2005, it needs to be mapped into the application either using SQLMetal or the designer. The first time around is not Read More...
|
-
Hi, I was wondering why the OnLoaded partial method was not given the oppotunity to know about its current DataContext. I mentionned that in an earlier post but did not get any feedback. I've seen an answer to another of my interrogations here (why is the OnCreated call before full initialization of the object), so I take a chance at asking again. Getting a reference on the DataContext when the object is loaded would give the object access to the outer world and a chance to cache some relevant runtime Read More...
|
-
Hey, I have a problem - I can't update my DataContext and thus the DataBase This is the code: NorthwindDataContext dc = new NorthwindDataContext(); List updatedDetails = (List)dataGridView1.DataSource; dc.Order_Details.AttachAll(updatedDetails); dc.SubmitChanges(); however this does not update the datacontext dc I tried using foreach(Order_Detail od in updatedDetails) {dc.Order_Details.Attach(od);} however that didn't work as well. Any help would be appreciated Read More...
|
-
I want write a method that combines two lambda expressions of the same type using a specified operator (‘And’ for example). The problem is that the two expressions don’t have the same set of parameters, so I need to replace the parameters from one of them. I didn’t find an easy way to do that, the only possibility was to use the InvocationExpression, but I don’t really like how the result expression looks. This is the code: Code Snippet static Expression Func > CombineErr( Expression Func > a, Expression Read More...
|
-
In the CSharpSamples\LinqSamples\WhitePapersStandard Query Operators.doc shipped with Orcas2 it says: "The examples shown in this specification are all written in C# 3.0 and assume that the Standard Query Operators have been imported with the using clause: using System.Query; However when I try the above line I get an error: D:\CSharpProjects\LambdaExpressions\FunctionalProgramming\FunctionalProgramming\Program.cs(5,14): error CS0234: The type or namespace name 'Query' does not exist in the namespace Read More...
|
-
Hi, it would be great, if this Entity-Objects have to become SupportsFiltering = true! Is this projected for the RTM? We would to migrate Visual-Foxpro-Apps with many sql-based businessrules to .NET, but there is no SET FILTER TO - like feature. We would use Dlinq as an replacement for Typed Datasets (here is SupportsFiltering = true). -christoph Read More...
|
-
Hello all I'm very interessed to learn LINQ. The problem is, that I don't know where to start. Maybe you can tell me which scripts I have to read, probably some step by step guidance or so... I am new in .NET but I thought LINQ will be more than only an alternative to the conventionally kind of database acces. Primary i am interessed in learnig dLINQ. Thanks for your answers Read More...
|
-
The code generated by the linq designer currently looks like this: Code Snippet public Choice() { OnCreated(); this._EventResults = new EntitySet(new Action(this.attach_EventResults), new Action(this.detach_EventResults)); this._Event = default(EntityRef); } (EventResults and Event are a 1-n and n-1 associations.) OnCreated is a partial method which allows me to insert custom initialization logic into the Choice class. That's great. But I think it should definitively happen after the linq generated Read More...
|
-
Is there any sensible reason not to raise the ListChanged event of EntitySet if its IsLoaded property is false ? I don't think so. I just spent one hour trying to figure out why the following simple scenario doesn't work: Code Snippet var choice = new Choice(); // choice.Results is an entityset (it's an association - generated by the linq designer tool) choice.Results.ListChanged += delegate { /* do whatever here, IT WILL NEVER GET CALLED */ }; choice.Results.Add(new Result()); // Notification wasn't Read More...
|
-
Hi, when trying to sum a decimal column (NOT NULL) in LINQ to Sql: bool sumZero = _dataAccess.GetTable().Sum(p => p.TestDecimalColumn) == 0; when the table is empty i´m getting this exception: InvalidOperationException The null value cannot be assigned to a member with type System.Decimal which is a non-nullable value type. I´m expecting Sum() on an empty table should return 0 and not null as the Exception shows... or is this behaviour by design? regards eiro Read More...
|
-
Hi there, I have this class: public class MyList : List{ } I made a query using LINQ over my table and I'm using ToList() method to convert the query result to List. but when I cast it to MyList class, I give a casting exception. What's your idea? Read More...
|
-
Hi, I created a new Linq to sql object with one table using orcas, when i build the project i get the Invalid token 'void' in class, struct, or interface member declaration at the following lines: partial void OnLoaded(); partial void OnValidate(); partial void OnCreated(); this code is generated..do i need to reference something in my project? ta Read More...
|
-
ie. something with a Business, Presentation and Data Layer. Read More...
|
-
XML Tools team has released the first CTP of the XML Schema Designer - a graphical tool for working with XML Schemas. You can download it from Microsoft Downloads site . This CTP introduces the Schema Explorer - a tool that helps you navigate, search and work with schema sets. You can view a short video of the new functionality here . Details Overview An XML Schema can contain multiple XML Schema files. The new XML Schema Designer lets you work with a schema set. That is, when you open an XML Schema Read More...
|
-
Are entities required to implement INotifyPropertyChanging and INotifyPropertyChanged? This appears in the generated entities and I'm not sure if this is used by the DataContext change tracking or is just a "nice to have" / best practice. I'm trying to figure out how PO my POCO's can be. :) Thanks in advance, Russell G Read More...
|
-
Here is the code in question: Code Snippet Dim xmlout = Order By Customer.CustomerID _ Select %> of that code the following is highlighted with the error, 'Expression cannot be converted into an expression tree" Code Snippet I can't see what's wrong. Anyone??? Read More...
|
-
Here is a quick preview of forthcoming changes in RTM compared to beta2: 1. Renaming of methods on Table / ITable We got substantial feedback after beta1 and at conferences indicating that Add()/Remove() methods were confusing or misleading for many users. The semantics of an INSERT or DELETE at the time of SubmitChanges() was not clearly conveyed by Add()/Remove(). The new names InsertOnSubmit()/DeleteOnSubmit() are more descriptive of the actual semantics. Note that there is no change in semantics Read More...
|
-
We're evaluating which ORM solution we're going to use for our web version of our software right now and I'd like to not have to use anything other than what is in the .NET framework. I'm not happy that Linq to Entties isn't going to be part of the framework and that we don't have a version that works with Beta 2 yet because I'd really like to use Entities and not be database specific, but... Anyhow, I've been trying to use Linq to SQL to try and duplicate our system without having to reproduce a Read More...
|
-
Hello; I'm a computer enginnering student at Turkey- Sakarya University.. I have a basic problem; I dont know whether this is a bug or not... I have a basic DB design like this When I want update the data that I get from TELEFON table I get an exception like this Value of member 'TelNo' of an object of type 'Telefon' changed. A member defining the identity of the object cannot be changed. Consider adding a new object with new identity and deleting the existing one instead. My code is like that Code Read More...
|
-
Maybe I don't understand this tech because I thought the idea was for this to replace typed datasets(xsd). I currently don't see how it can because no. 1 it doesn't seem to support a caption property that you can set to display column headings which is a minor ommission but more importantly it doesn't seem to support databinding in the since when you add and delete items in the datasource its not reflected in the control that its bound to. I've seen some workarounds(GetNewBindingList etc.) but they Read More...
|
-
Hi All Does anyone know whether support for SQL Server 2008 (Katmai) will be included in the release version of SqlMetal and thus in Visual Studio 2008? I am intending to use LINQ for the data layer in a new project and want to take advantage of the out of table binary persistance feature in Katmai. Regards Gavin Glynn :) Read More...
|
-
We are porting LINQ CTP code to Orcas Beta2, and come up with one problem regarding the QueryExpression: Expression expression = QueryExpression.Where(sequence.Expression, predicate); expression = QueryExpression.FirstOrDefault(expression); I understand we need to use DynamicExpression to replace the above-mentioned code snippet, but don't know how, anyone who can kindly provide some migration thoughts. Note that DynamicExpression class is in Dynamic.cs in the folder C:\Program Files\Microsoft Visual Read More...
|
-
Should it be the rule that in ASP.Net when datacontex is short lived, that it should be enclosed withing a "Using " statement? a) Is that a good practice? b) Is it necessar? c) Makes no difference! Using (DBDataContext MyDb = new DBDataContext()) { // Codes that use MyDb //... } Read More...
|
-
Hi; Although this question is unrelated to Linq, but since everyone here uses SQL2005, I thought it's a good place to ask. I need a light weight management tool for creating database, tables, fields, indexes and FK. A tool that is easy to use, to view fields and quick to add fields one after another. The SQL Management Studio is great, but I like to have something on the side for quick changes. I looked around and the few that I found are bigger and more cumbersome than SQL Studio. Any recommendations? Read More...
|
-
If the initial value of a property is null, there seems to be no way to reject the null value in the setter because the validation code in OnNameChanging(value) is not even executed. So the assignment like this: myEntity.Name = null , executes silently without any warning. Should LINQ enforce " CanBeNull=false " on a setter? [Column(Storage="_Name", DbType="NVarChar(30) NOT NULL", CanBeNull=false, UpdateCheck=UpdateCheck.Never)] public string Name { get { return this._Name; } set { if ((this._Name Read More...
|
-
Hello, I've posted this question on a few other forums and I'm getting no response at all so I think maybe it's i nthe wrong forum so I'll try here. I just need maybe a nudge in the right direction. I wanted to have a datagridview that gets it's data from two tables off my SQL2005 server. I have a table lineitems and a table vendors. The linelitems table has a field: VendorID which is a foriegn key for the vendor table. I can't ever seem to get the data source working whereI pull it over and it auto Read More...
|
-
I'd like to pass a string which is a LINQ query to a function and have it execute the query and return the appropriate results. Are there any samples for this? The key is that the query is not known until runtime. Read More...
|
-
I'd like to pass a string which is a LINQ query to a function and have it execute the query and return the appropriate results. Are there any samples for this? The key is that the query is not known until runtime. UPDATE: I am not looking to do SQL queries or queries against a database. I am doing in memory queries against some collection and don't know the query until runtime. CHALLENGE: Pass the query in as string type and execute it against an object array or Dictionary For instance Class DoHick Read More...
|
-
Hi All, I am evaluating LINQ as a platform to replace out current data persistance layer (against SQL Server 2005). I am keen to use stored procedures, and have found the LINQ support to be good. One issue I am having is with getting optimistic locking to work. I perform the following steps: * Open a database context against our database. * Retrieve a LINQ entity from the database via a stored procedure (i.e. a "user" record). * Change the properties on the "user" object. * Directly access the database Read More...
|
-
Hey, I want to make sure im using linq the right way in my project, I hope someone will take a few minutes to help me in the right direction here :) I have created a "LINQ to SQL Classes" to my project, which includes for example "Files". I have then created a new partial class called Files, where I define some of my own methods for Files. So when I want to make a list of files I can easilly make the following linq: var Files = from f in db.Files select f; which returns a list of File objects with Read More...
|
-
I've noticed a behavior in the LinqToSql framework that I did not expect. I set up a simple test, essentially to just read the same record from a table twice. Between the "reads" I updated the record via Server Management Studio. As might be expected, the second "read" from the DataContext.Table<> still had the stale data. The thing that seems odd is that even though the data was stale, the database was queried a second time with a query identical to the first. I'd have thought that if the trouble Read More...
|
-
Assuming I start with myOrder.ItemsLeft which contains exactly 1 card item, then if I run this code: Code Snippet ItemsLeft existingCard = ( from i in myOrder.ItemsLeft where i.Item.Type == Constants . Item . Type .Card select i).First(); myOrder.ItemsLeft.Remove(existingCard); Globals.db.SubmitChanges(); on SubmitChanges(), I get the following exception: "An attempt was made to remove a relationship between a Order and a ItemsLeft. However, one of the relationship's foreign keys (ItemsLeft.OrderID) Read More...
|
-
Hello, My question is pretty easy I guess. I have a DLINQ class "MyClass" associated to an SQL Server table. I have attributes, with [column...] tags. It works fine. Now I would like to add an attribute to the class which won't be stored in my DB, so I didn't add the [column ] tag over it. I have no access to it through Linq.Table and DLINQ requests. Is there a way so that this attribute can be accessible without being stored as a column in the DB ? Actually it is initialised in the constructor of Read More...
|
-
Hi, I was having a problem with removing rows from my database with LINQ so I searched the "LINQ to SQL Overview February 2007" for a explanation. I found a pretty similiar example at page 21. Code Snippet var db = new NorthwindDataContext (); Customers cust = db.Customers.Single(c => c.CustomerID== "ALFKI" ); // Pick some order Orders o = cust.Orders[0]; // Remove it directly from the table (I want it gone!) db.Orders.Remove(o); // Displays ‘false’.. gone from customer’s Orders Console .WriteLine(cust.Orders.Contains(o)); Read More...
|
-
If you refresh one object with a DataContext.Refresh call, it seems that the library refreshes the object the "hard" way and doesn't call any PropertyChanged notifications. Consider the following scenario. I have a WPF TextBlock whose text is binded to the Name property of a simple entity retrieved with LINQ to SQL. Let's say I change the Name from "titi" to "tata". So far everything is nice and the binding is refreshed. My GUI is in synch with my data. Now step 2: let's say I want to cancel my modifications Read More...
|
-
How to convert the following code from C# to VB? public void StartWorkflow(Type workflowType,Dictionary inparms,Guid caller,IComparable qn) { WorkflowRuntime wr = this.Runtime; WorkflowInstance wi = wr.CreateWorkflow(workflowType,inparms); wi.Start(); ManualWorkflowSchedulerService ss = wr.GetService(); if (ss != null) ss.RunWorkflow(wi.InstanceId); EventHandler d = null; d = delegate(object o, WorkflowCompletedEventArgs e) { if (e.WorkflowInstance.InstanceId ==wi.InstanceId) { wr.WorkflowCompleted Read More...
|
-
How to convert the following code from C# into VB? void WidgetDataList_ItemDataBound(object sender, DataListItemEventArgs e) { if( e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem ) { Widget widget = e.Item.DataItem as Widget; LinkButton link = e.Item.Controls.OfType().Single(); link.Text = widget.Name; link.CommandName = "AddWidget"; link.CommandArgument = widget.ID.ToString(); } } Please help......thanks! Read More...
|
-
How to convert the following code from C# into VB? private void SetupWidgets(Func isWidgetFirstLoad) { ... } protected override void CreateChildControls() { this.SetupWidgets( wi => false ); } Please help....thanks! Read More...
|
-
I know you can create objects from databases using say Linq to SQL, but is it possible to create database tables from objects (or xml) using any of the Linq technologies? If not, anyone know how? Thanks Danny Read More...
|
-
Looking for suggestions, resources, possible rumors on the following 1. Can we instruct Linq to Sql to utilize custom types as part of a CRUD operation? For example, we need to let some of our custom types get a look at the outgoing data before Linq completes the operation. 2. Can we expect Linq to work with the new synDesigner\SQL Compact Edition? 3. Somewhat related to question #1, can we instruct Linq to utilize a WCF endpoint for CRUD based operations on the client? My idea is to keep the programming Read More...
|
-
Hello, I have been experiencing something weird and wanted to share it with you in the hope of finding a solution for it! I have a table in the Database that has some nvarchar fields and 3 boolean fields: Approved, CommentsEnabled, and OnlyForMembers. when I try to update the article by unchecking the Approved checkbox on the web form, and using SQL Profiler, I can see that the update statement generated by LINQ is not taking into consideration the Approve field which I have changed!! I also used Read More...
|
-
Hi, I have the following code: Code Snippet ItemsLeft newCard = new ItemsLeft () { Item = cardItem, Order = this }; Action newAction = new Action () { ReferenceID = newCard.ID, Order = this }; Then, in another code block elsewhere I'm calling SubmitChages(). But after the save is complete, ReferenceID is saved with a value of 0 instead of the database auto-generated newCard.ID. Since the code must call SubmitChanges() from somewhere else, I cannot try forcing the save order by wrapping in a transaction Read More...
|
-
I have a call public List Method1(Expression> exp) where T is a proxy object, having same structure(properties) as a linq database object of type L. And within a method body, I need to call List lst = base.Method1(exp1); where exp1 is (Expression> ) basically I need to convert exp of type T to the same kind of expression of type L something like: public List Method1(Expression> exp) { List lst0 = new List(); foreach (ParameterExpression prm in exp.Parameters) { ParameterExpression p = Expression.Parameter(typeof(L),prm.Name); Read More...
|
-
Well not really a bug in the code. but a logic error. When you have a one to one relationship in a dbml linq file between a primary key and a child in VS 2008 Beta2 The generated code is wrong when setting the entity in the relationship from the table with the primary key. say you have two items with a relationship with Item and a POItem - Item has a primary key of ID POItem has a linking field of itemID; after generating the code: if you try to call Code Snippet item.POItem = new POItem(); in the Read More...
|
-
|
I'm looking for a way to pass a local list with key values to a LINQ for SQL query. My list contains 2 key fields : Pro | |
|