|
|
July 2007 - Posts
-
Wouldn't it be useful to provide a version of DataRowComparer that would support typed DataSets? The current implementation supports only DataRow objects, and not typed DataRows. Here is a DataRowComparer that I created to support typed DataSets: Code Snippet public class DataRowComparer : IEqualityComparer where TDataRow: DataRow { public bool Equals(TDataRow x, TDataRow y) { return DataRowComparer.Default.Equals(x, y); } public int GetHashCode(TDataRow obj) { return DataRowComparer.Default.GetHashCode(obj); Read More...
|
-
Hi Everyone, How would one go about creating a query based on user-selection. For example, I have a list box showing the possible columns (fields) I'd like to include for a DataGridView to display the query result. I'm kind of thinking about setting it up like this: Code Snippet var query = from docs in db.Documents select docs; foreach ( string field in selectedfields) { if (field == "Document_Number" ) { query = from docs in query select new { docs.Document_Number }; } if (field == "Revision_Number" Read More...
|
-
I'm playing with LINQ To SQL with a WinForms application, and I don't completely understand how to best manage the lifetime of the datacontext. Let's say I have a grid that I load data into. The user can scroll through the data and add, modify, or delete records. Adding and modification is done through a separate dialog. My loading code looks something like this (simplified): public static class CompanyHelper { public static List LoadCompanies() { using (MyDataContext context = new MyDataContext()) Read More...
|
-
I have a function which returns an IOrderedEnumerable... I then do a query against it to specify a single record. However, the query naturally returns an IEnumerable when I only need the XElement. Is there any way to get the query to only return a single XElement? If not, is there a way to get the single XElement without using a foreach loop? Read More...
|
-
I have the following tables (only relevent fields shown): Groups: GroupID GroupName Users: UserID UserName UserGroupMapping: UserID GroupID When I set up structure in the LINQ designer with Groups-->UserGroupMapping Code Snippet var UsersInGroup = from g in X.Groups where g.GroupName == "TestGroup" select g.UserGroupMapping.Users; When I use " from u in X.Users" I don't see u.UserGroupMapping as I would have thought since that is defined in the parent relationship. I looked in the designer.cs file Read More...
|
-
Hi! I have this: IList int > numbers = new int [] { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; Expression parameter = Expression .Parameter( typeof ( int ), "x" ); BinaryExpression binaryExpression = Expression .Or( ConditionalExpression .LessThan(parameter, MemberExpression .Constant( 5 )), ConditionalExpression .GreaterThan(parameter, MemberExpression .Constant( 7 ))); what should i do next to evalute the expression "binaryExpression" on the list "numbers"? This binary expression would find in numbers where Read More...
|
-
Now, that I’ve laid the groundwork defining a reusable version of IQueryable and IQueryProvider, namely Query and QueryProvider, I’m going to build a provider that actually does something. As I said before, what a query provider really does is execute a little bit of ‘code’ defined as an expression tree instead of actual IL. Of course, it does not actually have to execute it in the traditional sense. For example, LINQ to SQL translates the query expression into SQL and sends it to the server to execute Read More...
|
-
In Beta 2, the "class" constraint has been added to the Table type. This has totally broken my design because I was using interface types as the generic parameter. I will unfortunately now either have to totally redesign my data access layer or take control of the generation from SQL Metal. What is the reason for this change? Is this changed expected to be present in the final release? Read More...
|
-
i know i can write code like this: Code Snippet List ReadEntities() where T : class { //db is DBContext var tCollection = from tObj in db.GetTable() select tObj; return tCollection.ToList(); } to dynamically return a List of entities. However if i wanna add some condition, how it should go? i need support Generic. Thanks Read More...
|
-
I dont see anything in the .xsd for the external mapping file, how do I tell an Association to lazy load or not? EDIT: This is for LINQ to SQL. Read More...
|
-
I have table Event and table EventTypes which hold available event types. Event table has EventTypeID column which has one-to-many relationship with EventTypes. Generated code throws System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException() exception when i'm trying to change EventTypeID: event.EventTypeID = 2; EventTypeID Setter looks like this: set { if ((this._EventTypeID != value)) { if (this._CL_EventTypes.HasLoadedOrAssignedValue) { throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException(); Read More...
|
-
Hello DLINQ Team, I have an important question to raise. Can MS guarantee a support for DLINQ throughout the next 10 years? Will MS continue DLÍNQ even when Entity framework hits the road? Will it be guaranteed that the Framework get fixes if there are serious bugs. With MS Repository there have been a number of issues were none of them were addresses in the last 6 years and for each one the devs needed to work around. Similar things are with DataSets. There are still serious issues in the merge Read More...
|
-
Forgive my ignorance, but is there a way to use LinQ to SQL in the implementation of an SQL trigger in such a way that the built-in inserted/updated/deleted collections provided by the trigger context connection can be accessed via a type-safe DataContext? What I'd like to do is write something like [SqlTrigger(Name = ..., Target = "[dbo].[OrderDetail]" , Event = "FOR INSERT, UPDATE" )] public static void LinQTrigger() { switch ( SqlContext .TriggerContext . TriggerAction) { case TriggerAction.Insert: Read More...
|
-
public void GetNames() { DataContext db = new DataContext("Data Source = xxxxx;initial catalog = tttt;user = ddd;password = for;"); Table detailslist = db.GetTable(); var names = from c in detailslist where c.Name == "Dhina (.net)" select new { c.Name,c.Team }; GridView1.DataSource = names; GridView1.DataBind(); when i run this code, i get the following exception at the line which is bold. The exception is Value cannot be null. Parameter name: method by the way,, what is the functionality of GetTable Read More...
|
-
-
Hello, I've created a dbml file in VS 2008 Beta 1. Now I've updated to VS 2008 Beta 2, but now I'm not able to load the dbml file. When I try to open the dbml file, I get following message box: "Cannot load D:\.....dbml: Error encountered, check Error List window for details" And the error list says: "DBML1113: Database node not found. Is the DBML namespace ( http://schemas.microsoft.com/linqtosql/dbml/2007 ) correctly specified?" When I try to compile the project, I get following: Error 1 Build Read More...
|
-
Hi, I want to automatically redisplay parts of my form whenever an order is added or removed from my customer. I thought I could subscribe to the PropertyChanged() event, but there is a problem: Customer.Orders.Add(newOrder) calls PropertyChanged("Orders") which I've set to call ReDisplayOrders(); But, when ReDisplayOrders is called, the order that I'm adding is still not in the Customers.Orders collection. It doesn't appear in the collection until after it returns completely from Customer.Orders.Add(newOrder). Read More...
|
-
I’ve been meaning for a while to start up a series of posts that covers building LINQ providers using IQueryable. People have been asking me advice on doing this for quite some time now, whether through internal Microsoft email or questions on the forums or by cracking the encryption and mailing me directly. Of course, I’ve mostly replied with “I’m working on a sample that will show you everything” letting them know that soon all will be revealed. However, instead of just posting a full sample here Read More...
|
-
Trying to learn LINQ to SQL, and I am getting this exception: The column or association 'Id' in the mapping had no corresponding member in type 'Portfolio'. Mapping members from above root type is not supported.. I suspect something is wrong with my mappings.xml file. I am doing some very basic inheritance, here are my classes: Code Snippet public abstract class DomainObject { protected int id; public int Id { get { return id; } set { id = value; } } protected DateTime created; public DateTime Created Read More...
|
-
the below code is failing on this line: ENTITY original = (ENTITY)table.Single(entity => entity.Id == updated.Id); I've newed up a new DataContext. I'm simply trying to implement an update method to get the original object back from the database so I can attach the modified object and I'm receiving the following exception: Object reference not set to an instance of an object Here's my code and stack trace: Code Snippet public void Update(List entitiesToUpdate) { CoreDataContext db = GetWriteableDataContext(); Read More...
|
-
Ok the short and the sweet of this problem is the following: This error occurrs in the constructor of a datacontext: Line 46: public Table Remedy; Line 47: Line 48: public Database() Line 49: : base(System.Configuration.ConfigurationManager.ConnectionStrings["Security"].ConnectionString) Line 50: { The CATCH IS that the same code works on a different machine. If I copy the code over and run it in IIS then it is fine but the moment I open the solution in ORCAS and recompile things go wrong. The long: Read More...
|
-
I’m shocked. I thought that for sure there will be option for custom attributing in l2s designer (and sqlmental) generated source files. It seems that there is no such option on columns. ????? WHAT ????? Dinesh writes : “custom attributes are not supported by the designer or SqlMetal in beta2 or RTM version” So I thought that for sure it will be possible via additional partial class file decoration. I tried and… ooops. No way Additionally Jim writes: “Downside to the partial class implementation Read More...
|
-
More and more LINQ -> SQL articels and good samples are surfacing each day. But all seems to be rather rapid / basic. Sample applications with a some "patterns & practices" way to do things would be great. For ex. the dinnernow application has "EntityTranslators" classes (good or bad). In some applications my BLL and DAL are in different assemblies witch would make tha partial classes an issue. The "scope" of the contextclass is another thing, should you go with one contextclass or several, depending Read More...
|
-
I'm wondering if any operator translates to SQL 'IN'? I want to write something like Code Snippet string[] assigmentGroups = { "One", "Two", "Three" }; var q = from c in this.CallLogs where c.Assigments.In(a => a.Assignee, assignmentGroups) orderby c.CallID select c; That translates to ... [t1].[Assignee] IN ('One', 'Two', 'Three') Read More...
|
-
I got a few mails and saw a few forum posts about the confusion created by new locations for dll/exe in beta2. So here is where you can find LINQ to SQL related files. New .NET Framework 3.5 DLLs ( ">green bits ) are in: Program Files\Reference Assemblies\Microsoft\Framework\v3.5\ SqlMetal.exe is in Program Files\Microsoft SDKs\Windows\V6.0A\Bin\ Another source of confusion - designer vs. SqlMetal The visual designer for generating mapped LINQ to SQL classes is a part of Visual Studio 2008. You need Read More...
|
-
Introduction Annotations can be used to facilitate transforms of an XML tree. Some XML documents are "document centric with mixed content." With such documents, you don't necessarily know the shape of child nodes of an element. For instance, a node that contains text may look like this: [xml] <text>A phrase with <b>bold</b> and <i>italic</i> text.</text> For any given text node, there may be any number of child <b> and <i> elements. This approach extends Read More...
|
-
I am having a problem with LINQ and I don't know if I am doing something wrong or if this is a bug in the software. I have an Entity that has two fields ID, Name. ID is a System.GUID and Name is a string. I configured the ID field to be a RowGUID in SQL server so the value is generated on insert. I then configured the ID field in my LINQ to SQL entity and set it as Auto-generated and to Auto-sync on insert. When I try to insert a new entity and call the SubmitChanges() method on the DataContext I Read More...
|
-
when generating from an MDF file? In previous versions, it has. Is it the permanent behavior that it will not automatically attach the database? Thanks. Read More...
|
-
In beta 2, the System.Data.Linq.dll file is in C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5 instead of C:\WINDOWS\Microsoft.NET\Framework\v3.5. What is the thought here? Are the system.*.dlls no longer going to be in C:\WINDOWS\Microsoft.NET\Framework\v*.* directories? Read More...
|
-
I was wondering how I apply the DataContract and DataMember attributes to an Entity generated by the O/R Designer in VS 2008 for Linq to SQL. I would like to expose a service via WCF that uses LINQ in the backend for data interactions. I understand that LINQ is not a distributed platform, which doesn't matter because the client should have no idea (or care) that I am using LINQ in the first place. The problem I came across is that I don't seem to beable to edit the classes the Link to SQL designer Read More...
|
-
What's the nicest way of dealing with XML that has a xml namespace declared? Everything I see shows examples like this: xe.Elements(ns + "MyElement")... That seems really annoying. Isn't there any way I can tell it to just look at the local names or specify a default namespace? -Michael Read More...
|
-
If I have a database with alot of tables, I would split it into a few .dbml files that make sense (as suggested in other threads). For some hypothetical reason, I need the Order in 3 different dbml. This will create 3 Order classes that look alike (by default) with different namespace. Each of the 3 DataContexts could be used to create an Order and Save it to the Database. But I want some logic in my classes that does very intelligent checking before an Order is saved, so I actually want to be able Read More...
|
-
I was playing around with LINQ today and wondered why code like this won't work: Code Snippet var query = from o in db.Orders select o; foreach( var order in query ) { Console.WriteLine("Order Number: {0}" , order.OrderNumber); foreach( Product in order.Products ) { Console.WriteLine("Product: {0}", product.Name); } } Why doesn't LINQ allow me to navigate related entities like that? It compiles fine but doesn't print the products. Read More...
|
-
Now that .NET 3.5 and VS 2008 are "Feature Complete" is there a list showing the differences. My specific problem is the the .DBML file structure changed and the Custom Attributes property in not in the properties dialog for LINQ to SQL classes. Guesses?? Read More...
|
-
Hi NG, Is there any documentation about the changes between beta 1 and beta 2? I'm looking for the GetQueryText and GetChangeText Commands... But they are no more under DataContext class. Thx for your help, Ozgur Aytekin Read More...
|
-
Hello, With the LinqDataSource, when I select all of the columns (*) I can edit and delete records via a GridView however, if I select only certain columns the options are not available - even if I select all the columns. Secondly, if I go direct to the object and not via the DataContext and select * for all columns, I don't get Update and Delete functionality. Would be great if these two scenarios where supported. Hope this makes sense. Ben Read More...
|
-
If i write my LINQ code in notepad then all i need is a LINQ compiler and dot net framework which supports LINQ, as for the framework I know versioon 3.5 beta 2 is out, i can use that. What abt the compiler, will i also get SDK with the framework? Will I be able to work just with the framework? Read More...
|
-
I'm hoping to replace my "partial class properties map ints to enums" code on my generated LINQ classes (a hack from Beta1 timeframe, since enum mapping wasn't turned on yet). It looks like all the pieces are in place to allow automatic enum mapping in Beta2, and the docs seem to think so as well... However, even in a little dummy project, I'm getting no joy when I set the Type property of an Int or Int NOT NULL column to my enum type (Mapping between DbType 'Int' and Type 'AnApp.AnEnum' in Column Read More...
|
-
Hi, After upgrading to VS 2008 Beta 2 i get this error on a LINQ Query wich worked on Beta 1. Unable to cast object of type 'System.Data.Linq.SqlClient.SqlJoin' to type 'System.Data.Linq.SqlClient.SqlAlias'. The query: var forums = from f in context.Forums where f.tMandant.id == Helper .CurrentMandant.id orderby f.SortOrder select new { id = f.id, Name = f.Name, Description = f.Description, Topics = f.ForumTopics.Count, Entries = ( from t in context.ForumTopics where t.Forum1.id == f.id select t.ForumMessages.Count).Sum(), Read More...
|
-
How I can select just a filtered set of a child table, p.ex.: parentTable.First parentTableType >().childTable.Where( "...") ? I know there is a "Where<>" method but I did not realize how to use it. Thanks Read More...
|
-
Hi, Can somebody explain me the reason why LinqDataView has been made internal in System.Data.DataSetExtensions.dll in Beta 2 (it was public in Beta 1)? Is it going to "come back" in final product or is being superceded by some other class/technology? Txs and regards, Octavio Read More...
|
-
After updating a project to Beta2, I am getting errors indicating that System.Collections.Generic.List does not contain a definition for 'Last' (or any of the other standard query operators). Also, I get an error "The type of namespace name 'IQueryable' could not be found (are you missing a using directive or an assembly reference?" My using statement is as follows: using System; using System.Data; using System.Configuration; using System.Data.Linq; using System.Web; using System.Web.Security; using Read More...
|
-
After installing Beta 2, I recreated my entities with the designer, but upon trying to compile I get the following error messages: Error 1 The type or namespace name 'Objects' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) C:\Users\Kash Monsefi\Development\Customers\Customers\Customers.cs 22 66 Customers Error 2 The type or namespace name 'Metadata' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) C:\Users\Kash Monsefi\Development\Customers\Customers\Customers.cs Read More...
|
-
Orcas beta2 is here for you. This is significantly ahead of beta1 and pretty close to the final feature set of Orcas for most components. The releases are available both as regular installs and as VPC images . Now that Orcas beta2 has been released, it is time to look at what's new there. But first, a general sense of how beta2 shaped up. Beta1 released in spring was mostly productization of the May 2006 LINQ CTP. So those who played with it only a little bit did not see a big change over May 2006 Read More...
|
-
I thought that SQL Server CE was going to be a supported provider for linq to sql on Beta 2, i updated my C# Express to beta 2, and am still getting "The selected items use an unsupported provider" when dragging the tables to my new linq to sql designer, is my information wrong? or am i doing something wrong? I want to use linq in a desktop application, but obviously I can't send a full sql server db along with it... if this isn't going to be supported, what is the best way to do this in beta 2? Read More...
|
-
Since Soma's done a nice job of summing it up: http://blogs.msdn.com/somasegar/ The bits are available at http://msdn2.microsoft.com/en-us/vstudio/default.aspx Enjoy :) Read More...
|
-
I have a test database set up with just four fields: int Identity key field, nvarchar, int data field, and datetime field. Naturally the key field is marked by SQL server as not nullable while the rest are defaut nullable. Orcas O/R designer generates the 'testTable1' class with the key field as read-only which caused the wsdl serializer to throw and exception (missing 'set' command) which can be cured by setting the read-only property to false. A potiential problem exists, but it works. Note for Read More...
|
-
The following style of query throws a NotSupportedException in the June CTP: from p in dataContext.Purchases group p.Price by p.Date.Year into salesByYear select new { Year = salesByYear.Key, TotalValue = salesByYear.Sum() }; NotSupportedException: Aggregate operators are not supported in projections. Cha nging salesByYear.Sum() to salesByYear.Sum(x=>x) works around the problem. Cheers Joe Read More...
|
-
Statement: from a in b join c in d on a equals c select... works as expected but: on c equals a throws error: The name 'c' does not exist in the current context. Regards. Read More...
|
-
Not sure if this is a bug or I am just doing something wrong. Basically, I have a simple windows form that preloads some employee data and prefetches their roles using a datashape. The UI contains 2 pages... 1 displays a list and as the list selection changes a label is updated with the role for the selected employee. This works fine and I can see no additional sql statements are being executed to fetch the roles. The problem is that the other page displays a datagridview and a drop down box. What Read More...
|
-
Dear NG, Using DatabaseExists Method, I can check if the given Database is existing or not. Is there any way to check (using LINQ to SQL) if a Table or a Column is existing in my Database or in a Table? Thx for your help, Ozgur Aytekin Read More...
|
-
Will there be some thing like a LINQ plug-in for Visual Studio 2005? Read More...
|
-
Hi, I already use LINQ in WPF and mobile project. Today, i would like to try linq in ASP.NET : Code Snippet using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Linq; using System.Data.Linq; using System.Collections; using System.Query; public partial class _Default : System.Web.UI. Page { [ Table (Name= "News" )] public class Article { [ Column (Name= "id_news" )] public int id; public string Read More...
|
-
Hi, I already use LINQ in WPF and mobile project. Today, i would like to try linq in ASP.NET : Code Snippet using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Linq; using System.Data.Linq; using System.Collections; using System.Query; public partial class _Default : System.Web.UI. Page { [ Table (Name= "News" )] public class Article { [ Column (Name= "id_news" )] public int id; public string titre_news; public Read More...
|
-
the stored procedure if CreateDatabase() is called? Since the code that is generated is calling the ExecuteMethodCall(), it seems like it should be a done deal that it is calling a stored procedure, so I am guessing that the StoredProcedure attribute is just for when CreateDatabase is called. Is this correct? I guess if the stored procedure is named differently than the method, the StoredProcedure attribute is necessary so the Name attribute property can be specified, but I am talking about the cases Read More...
|
-
This might be cockpit error on my part, but I'm encountering errors when running C# or VB query expressions that I understand the language compiler should translate to the SelectMany standard query operator. In the following code examples, the CustomerList source collection contains an Orders field of a List(Of Order) type (per the customers collection of the "Standard Query Operators" white paper (June 2006), and txtResult is a multi-line text box. The commented query expression of the Read More...
|
-
It seems I can't define extension method for a class with name "Add" and use it with collection initializer for the class simultaneously: The member initializer does not have an identifiable name . It would be useful feature to fix "legacy" code quickly.For example "XsltArgumentList" has "AddParam" method that draws it completly useless for new "initializers" trend-compiler can't recognize it. Thanks. Read More...
|
-
Hi all I have recently installed Orcas Beta 1 wanting to play with linq. I then noticed a July CTP for Entity Framework and decided to install that. EF required Visual Web Designer, so I got that. Everything installed ok. Played with linq a bit, then found Orcas crashed a lot. After reading the install notes (yes, I know, after the fact, but 20/20 hindsight), I found that Orcas and Visual Web Designer don't make good neighbours (yet). So, I uninstalled both, repaired VS 2005, re-installed Orcas Beta Read More...
|
-
Hi, I'm little confuse about the two approach to data, what the different between Linq2Sql and Ado.net Entity? when I should use each one of them? thanks Adiel Read More...
| |
|