|
|
December 2008 - Posts
-
Hello I decided to build my new project with linq2sql, but still, i'm new with. So I wondered, Is there any caching solutions for linq2sql? or should I handle this caching by myself? For example, I fetched a single/multi row from a table, then after 5 min, from different instance of DataContext I need to fetch same rows. here I have too many db queries and performance drop, because the application will have to handle 10000+ users. So what's your suggestions? :) Thanks p.s. If I query twice using Read More...
|
-
sample1a sample1b sample2a sample2b sample3a sampl3b sample4a sample4b sample5a sample5b sample6a sample6b Read More...
|
-
Hi I need to have an application which is written in Visual C# 2008 talk to an application written in Delphi (Borland Studio 2006). Can this be accomplished using .NET? Web searches have not answered this question. Bob Read More...
|
-
Hi, I have page header and subreport which contain other set of data is in report footer. If the last record contains only subreport data and not any record from main data then page header should not display. I used NextIsNull but if few records from main data and subreport data are in last page (same page) then the page header is not displaying. Need help. Thanks, Chandru Read More...
|
-
How can we create tables in a datacontext using Linq to Sql like we can with Castle Activerecord's create schema. I created a class with Linq to Sql table() and column() attributes now I'd like to create the corresponding schema in the database. Is it possible with Linq to Sql? Read More...
|
-
Hi all, I am new to LINQ. I have add LINQ to SQL template into my application. I have successfully done Insert, update, select, and delete operations by using LINQ. Now i want to call a stored procedure from LINQ. Here is my code. DataClasses1DataContext ds = new DataClasses1DataContext(@"Data Source=DC;Initial Catalog=test;Persist Security Info=True;User ID=sa;Password=******"); List tech = (List)ds.sp_GetTotalTeachers(); but i am facing the following error... Unable to cast object of type 'SingleResult`1[VS2k8.LINQ.Teacher]' Read More...
|
-
Hi All, I am new to Linq ,can anybody help me to convert the following sql query to linq. SELECT Items . ItemsId , Items . SerialNum , Items . FirstRecieved , Catagories . Name AS CatagoriesName , Catagories . Description AS CatagoriesDesc , ItemTypes . PartNum AS ItemTypePartNum , ItemTypes . ModelNum AS ItemTypeModelNum , ItemTypes . Name AS ItemTypeName , ItemTypes . Description AS ItemTypesDescription , Catagories_1 . Name AS ItemTypeCName , Catagories_1 . Description AS ItemTypeCDescription Read More...
|
-
Hello, I'm new to LINQ. I started to practise by writing simple queries, but now I have a problem. I gave myself a simple task: a query which returns most common object in a List... for example, we have a List with values {"aa, "bb", "aa", "cc", "bb", "bb"} so the query should return "bb". I have no idea how to do this.. could anyone help me? Thank you in advance. Read More...
|
-
Hi I have one dll which is linq-sql, everything is automatically generate when I create it. I found in ths dll's app.config there is connection string. and then I have one app to reference this dll, and make them work together, it works very good. what I am going to do is I put database in one computer, and I connect my app to that database from another computer, I think I can do this by change connection string, but I can not find any connection string settings in my app exe.config file, it used Read More...
|
-
Hi, I'm using LINQ to SQL to get some data from Company table, the database is Unicode. After a few hours found out the record in the DB causing this error message, when the ToString() methos is called of the object XDoducment/XElement. I'm able to get the same record using the Dataset and when I serialize the dataset, the XML file is generated without any errors and I could view that file in IE but if I try to load the same xml file using XDocument.load I get this message. When the XML file is view Read More...
|
-
Sometimes an XML element contains a large number of attributes, and the values of the attributes may be long. When written to the console, such lines wrap, making it hard to read the XML. In particular, the XML responses from SharePoint web services often contain many attributes for each element. However, you can use appropriate settings for an XmlWriter so that the attributes are aligned, and each attribute is on a separate line. This post shows how to do this. XNamespace w = "http://www.northwind.com/examples/2008" Read More...
|
-
I'm new to LINQ and been reading a lot about it but I dont seem to find a good answer for this; Our app uses stored procs. We have a 3 tier app that uses ADO.Net, datasets etc. Looking at LINQ examples and trying some examples with stored procs, I find LINQ-Stored proc much simpler. My question is: why I would I want to learn/use LINQ language when I can just use stored procs. I can think of one reason; LINQ to SQL has deferred execution. Is any method better than the other? Read More...
|
-
hi i'm sorry for my bad english i want to use archive system on my web. thats for i wrote this code string year = Request.QueryString[ "y" ]; string month = Request.QueryString[ "m" ]; var results = fw.fwnews.Where(p=>(( DateTime )p.pubdate).Year== Convert .ToInt32(year) && (( DateTime )p.pubdate).Month== Convert .ToInt32(month)); archiveList.DataSource = results; archiveList.DataBind(); this code is runing on my local server. but it is not runing share hosting (godaddy) error message : The member Read More...
|
-
i keep getting a 1702 error msg stating that required script for install could not be run...i am trying to install logitech software for new web cam...thank you for your help...dave Read More...
|
-
Hi! I have DAL that uses more then one LINQ Datacontexts in a multi-thread environment. One thread executes a client query using a datacontext. My problem is that if one thread updates a tables using one datacontext, another thread with a different datacontextx does not see the updates. The first update changes the database table. If I execute a select on the latter datacontext, this select does not include the updates from the former. These tables have blobs, the changes are not automatically updated. Read More...
|
-
Hi, I have an entity that has seven relations to another entity type (table). The child table uses autonumber PK. I am communicating through WCF. When I try to add multiple new childs to a new parent object on the client and save, I first go through the child objects and attaches them to the datacontext in the DAL tier. Since many of the child objects can be identical I don't won't to clutter the database with many identical rows so I filter the child objects first and only attach 'distinct' objects... Read More...
|
-
Hi, How do I navigate from one tabitem to another at design time? Clicking the tabs, as I used to do it in WinForms, doesn't work. What I do now is change the SelectedIndex manually. Is there a better way? Thanks. Read More...
|
-
I've got a query like this: var query = from campUrls in db.CampURLs join codeCampLists in db.CodeCampLists on campUrls.CodeCampListId equals codeCampLists.Id select new CampUrlsSimple ( campUrls.UrlValue, campUrls.CampPrimaryEmailAddress); CampUrlsSimple is just a simple public class with two columns. When I execute the above sql without the Join (which in this simple example I don't need, but i do in my real world problem) I get the error: System.InvalidOperationException: Incorrect AutoSync specification Read More...
|
-
I just grabbed the new version of LinqPad and notice that to get autocompletion you need to pay for an activation key. Does anyone have any other community supported tools that helps with writing LINQ? I assume VS2010 will have better support for building LINQ but who knows. Read More...
|
-
Hi, One of the fields in my table has a default value. I drag the table from Server Explorer to the DBML designer. When I check the properties of the field with a default value, I see these: Auto Generated Value: False // should it not be True? Auto Sync: Never // should it not be Always? Read More...
|
-
Hi Guys am new to Linq I am using VS 2008 and SQl server 2005 (VB.net for coding ,C#is also fine) I need to know how can i use a function for deleting all the rows from a table using Linq query..Please let me know if u have any idea..It is very urgent..... Read More...
|
-
Hi, I want to keep a field in my entity as read only. I do this now at design time by setting the Read Only property of the field to true. However, when I refresh my dbnl from the db, the setting goes back to false. Is there any way I can prevent it from resetting? Thanks. Read More...
|
-
Hi, Say I do this Person p = dataContext.Persons.SingleOrNull() p.FirstName = newFirstName; p.LastName = newLastName; // etc, etc Before I call dataContext.SubmitChanges(), I'd like to see if the firstname was changed, and if it was changed to some specific value, I would like to restore the original value. What would be a good way of doing that? Thanks. Read More...
|
-
Hi , I am trying to update using linq , Here is my code. Dim db As New DataContext Dim data = From u In db.Items _ Where (u.ItemId = ItemID) data.First.LocationId = 5 db.SubmitChanges() I am getting the following error ' A critical error has occurred. Specified cast is not valid.' Please help me ASP. Thanks. Rob Read More...
|
-
True or False? LINQ TO SQL will not save an object correctly unless all of its member association lists (EntitySets) and look up objects (EntityRefs) are loaded in their entirety (with all of their respective children also loaded). If any of these child objects are null, LINQ to SQL assumes you want to delete the relationship, even if the key column for the association still has its value. If true, is there any way around this? Read More...
|
-
Sometimes you want to convert an XmlNode to an XElement and back again. Some programming libraries define methods that take XmlNode objects as parameters. These libraries also may contain properties and methods that return XmlNode objects. However, it is more convenient to work with LINQ to XML instead of the classes in System.Xml (XmlDocument, XmlNode, etc.) This post presents a bit of code to do these conversions. As an example of where you need these methods, you can do a lot with SharePoint using Read More...
|
-
Hi all, I have to questions concerning encapsualtion of linq statements. 1) Return value I would like to achieve the following: private ??? CreateLinqQueryForPrimaryKeys(TDTO dto) { var query = EntityTable.Where("1=1"); foreach(PropertyInfo pi in PrimaryKeysEntity) { query = query.Where(pi.Name + " = @0", pi.GetValue(dto, null)); } return query; } var detailsQuery = CreateLinqQueryForPrimaryKeysDetails(dtObject); 2) initialisation: As you might see I don't like the initalisation with EntityTable.Where("1=1"), Read More...
|
-
How do I write a WHERE clause that states the following criterias: Don't show lines where the location code is blank and Don't show lines where the location code begins with D I can do one or the other but haven't been able to get the correct code to do both. Thank you for your help, Read More...
|
-
Hello I am very new to VB.NET and LINQ so please be gentle.... How do I change the following code so I can get LINQ to query my custom collection:- Public Class Employee Private mName As String Public Property Name() As String Get Return mName End Get Set(ByVal value As String) mName = value End Set End Property Private mAge As String Public Property Age() As String Get Return mAge End Get Set(ByVal value As String) mAge = value End Set End Property End Class Public Class Employees Inherits CollectionBase Read More...
|
-
Hello everybody, I cannot figure out how to get this working: let's say I have the following query: 1) Subsitute columnname var detailsQuery = EntityDetailsTable.Where(DTOIDFieldname + " = "+ GetIDValueFromDTO(dtObject)); this results in a Operator '=' incompatible with operand types 'String' and 'Int32' exception Then I tried: var detailsQuery = EntityDetailsTable.Where("@0 = @1" , DTOIDFieldname, GetIDValueFromDTO(dtObject)); which resulted in a 0=1 where clause, so the placeholder didn'T get substituted. Read More...
|
-
I'd like to perform and handle a GroupBy event, but I don't know, or even care, about the types of the fields. I'd like to do something like this: IGrouping grouping; if (/* Some Condition */) { grouping = list.GroupBy(item => item.Number, item => item.Name); } else { grouping = list.GroupBy(item => item.Date, item => item.Name); } foreach (var outer in grouping) { Print(String.Format("{0}:", outer.Key.ToString())); foreach (var inner in outer) { Print(inner.ToString()); } } This won't compile, though, Read More...
|
-
Hi, How can I set UpdateCheck.Never for all entities when generating DataContext file? Read More...
|
-
I am happy to show some fields from this Sample file: http://www.traum-touren.de/develop/volsi.xml But i need moore: ->Group by DAT, Sum of KM (for Group), Average of AV (for Group) Who helps to enlarge this Snippet: Dim XMLele As XElement = XElement.Load("http://www.traum-touren.de/develop/volsi.xml") Dim SEL = From MD In XMLele.. Select MD..Value, _ MD..Value, MD..Value, MD..Value For results = 0 To SEL.Count - 1 Console.WriteLine(SEL.ElementAt(results)) Next This is my manually calculatet (wish)result: Read More...
|
-
Hi all, What is the recommended way to do optional where parameters in LINQ? for instance, let's assume i have the following query: var Orders = (from a in db.Orders select a) what if i have a method that searches on orders, and depending on what i pass in, i want to add them to a where clause, something like: var Orders = (from a in db.Orders if(!String.IsNullOrEmpty(OrderFullName)) { where a.FullName == OrderFullName } if(OrderDate > DateTime.Min) { where a.Date == OrderDate } select a) what's Read More...
|
-
Hello Everyone, I have a function that returns a list of type DataRow. When I have no results I get the "Sequence contains no elements" exception. I have seen solutions for "SingleOrDefault", but as I understand it, this will throw an exception if I have many sequences. By reading the description of the "Any" method it would seem to be the right solution. It is not. I still get the same exception, "Sequence...." I would like to find a solution that does not include trapping the exception. Any help Read More...
|
-
I have a struct public struct IPRange { private long ipStartNum; private long ipEndNum; public IPRange(long start, long end) { this.ipStartNum = start; this.ipEndNum = end; } public long IPStartNum { get { return this.ipStartNum; } } public long IPEndNum { get { return this.ipEndNum; } } } And function public static List CleanIPBlocksV3(List world) { List newWorld = new List(); foreach(IPRange ip in world) { var found = (from ip2 in world where ip2.IPStartNum >= ip.IPStartNum where ip2.IPEndNum where Read More...
|
-
Hi everyone, I have a LINQ object that has multiple relationships including 3 EntitySets. Each entity with the EntitySets contain EntitySets, and again so do each of these entities....... So in short I have a 4 tier relationship from the root object to the end of the relationship tree. I need to know if there is a way of deleting all the related records of the root object without having to iterate over all of the relationships. I dont think there is a way to make DataContext.DeleteOnSubmit() to behave Read More...
|
-
On Thursday, December 4, 2008 the Ecma General Assembly voted to approve Ecma 376 Edition 2 which is aligned on IS29500. This is good news for the Open XML standard and is the last step in the standardization effort for Open XML in Ecma - started 3 nearly years ago at the December 15, 2005 Ecma General Assembly. Doug Mahugh has a post that gives more information. There is an official Ecma statement on it here . This is what Paul Lorimer (Group Program Manager, Office Interoperability) had to say: Read More...
|
-
I am trying to put together my xsd and there is a nullvalue property assigned to each column. I have a column that represents a nested object so I have a table item with a foreign key relation to subitem. subitem might be null. How do I handle that. It won't let me set the nullvalue setting away from throws an exception because of course guids or integers (primary key of remote table and thus type of foreign key column) can't be null (value types). but since the class representation of these tables Read More...
|
-
Hi, (sorry if this is a re-post - my first one didn't seem to go through) I'm missing the set of LINQ project templates from my VSTS 2008 install. They don't appear in the dialog for creating a new project. (Yes, I'm targetting the 3.5 framework, so I would expect it to appear.) I've tried googling for the location of these template files, but all I can find are pages that reference the old CTP (which is, of course, old and not available anymore, since it's been released for a while now). So, can Read More...
|
-
Hi, I'm missing the set of LINQ project templates from my VSTS 2008 install. They don't appear in the dialog for creating a new project. (Yes, I'm targetting the 3.5 framework, so I would expect it to appear.) I've tried googling for the location of these template files, but all I can find are pages that reference the old CTP (which is, of course, old and not available anymore, since it's been released for a while now). So, can anyone tell me where I can find a zip, cab, or any other location that Read More...
|
-
Hi, my Question is with respect to Objects. I do have a List(collection) containing Customer objects, and the customer class is defined as below, containng name and collection of Order, inturn order containing description and collection of orderdetail, and orderdetail has product and quantity. How can i write a LINQ query to get a list of customers whose quantity is say more than 100 from a collection of Customer Object collection? Customer { string Name; List OrderList;} Order { string Desc; List Read More...
|
-
Hello Everyone, I am trying to find a solution for the following problem: I want different datasources (xml files, sql-database, mysql database, excel files, CSV files, XMLRPC-webservice...) to synchronize with each other. Each of these datasources contain one or more parts of information about Products, Customers, ... and the goal is to extract the relevant information and send it to a webshop (which uses an XML-RPC webservice, which i access using custom made functions). Therefore I want to create Read More...
|
-
Today, Microsoft published our first set of document-format implementation notes for the ODF implementation in Office 2007 SP2. These notes, which are available on the DII web site , provide detailed information about the design decisions that went into our implementation of ODF 1.1. See the press release for more information. Doug Mahugh has posted a comprehensive blog post on what the implementation notes are, why we published them, and some examples of implementation notes. From Doug’s post: “This Read More...
|
-
Hello all, I have three environments - dev, test and prod. My database is SQL Server 2005. I created a project of type "Class Library". To this I added a .dbml file. I then went to server explorer and dragged and dropped the tables onto the designer. All is good so far. I noticed that this action added two files: Settings.settings and app.config In both, the connection string is hard coded to my dev database. So my question is, is there anyway to remove it? In my UI (web), I have a config file where Read More...
|
-
I Hate to be a pain in the neck here but I really need to finish this. I never want to get the Sub-Elements of the Parent if Parent.swDocType = "sldasm" Dim query = From TopModel In xmlDoc... swModel > _ Where model.First.Ancestors( "swModel" ).Any( Function (stock) IsStocked(MyConnection, stock. swDetails > . @ swDocType, stock. swProps > . @ Number) = True ) Read More...
|
-
[Blog Map] One of the advantages of V2 of the Open XML SDK is that it provides us with a strongly typed XML document object model (DOM). Because elements are represented by classes, and attributes are represented by properties in the classes, developers are not at risk of misspelling element and attribute names. I was chatting about the Open XML SDK V2 with a customer, who appreciated the advantages of this approach. However, V2 of the SDK is not an option for them, because it won’t be available Read More...
|
-
Hi all Does anyone know how to generate a web service reference so the proxy class uses LINQ types such as XElement, etc? I am trying to use LINQ with Sharepoint Web services. I downloaded an example - full VS project - that has proxy classes with LINQ types. When I update service reference with my addresses, all this changes, and instead of XElement I now have XmlElement, etc. I tried to do it on command line by using svcutil with targetClientVersion:Version35 switch - does not make any difference. Read More...
|
-
Since MS is no longer going to grow the Linq2SQL, how do we know the same fate isn't going to appear for Entity Framework? Should w consider using nHibernate instead of Entity Framework? From my understanding, nHibernate and Entity Framework accomplish the same thing correct? Read More...
|
-
Any useful tutorials or videos that discuss Microsoft's entity framework? Thanks Read More...
|
-
p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in;margin-right:0in;margin-bottom:10.0pt;margin-left:0in;line-height:115%;font-size:11.0pt;font-family:'Calibri','sans-serif';} .MsoChpDefault {;} .MsoPapDefault {margin-bottom:10.0pt;line-height:115%;} @page Section1 {size:8.5in 11.0in;margin:1.0in 1.0in 1.0in 1.0in;} div.Section1 {page:Section1;} I am basically looking to remove Springframework (Adotemplate) to access store procedures and replace it with Linq. I have worked some with the designer Read More...
|
-
p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in;margin-right:0in;margin-bottom:10.0pt;margin-left:0in;line-height:115%;font-size:11.0pt;font-family:'Calibri','sans-serif';} .MsoChpDefault {;} .MsoPapDefault {margin-bottom:10.0pt;line-height:115%;} @page Section1 {size:8.5in 11.0in;margin:1.0in 1.0in 1.0in 1.0in;} div.Section1 {page:Section1;} I am basically looking to remove Springframework (Adotemplate) to access store procedures and replace it with Linq. I have worked some with the designer Read More...
|
-
If I have a data table, lets say it has the columns, ID, Address1, Address2, Zip Is there any way to map this table in LINQ to a class like the following, I know you can do this with Hibernate, but I haven't seen any examples of this with LINQ that don't entail creating a new table for the Address: class Table { public int ID { get; set; } public Address Address { get; set; } } public class Address { public string Address1 { get; set; } public string Address2 { get; set; } public string Zip { get; Read More...
|
-
I'd like to use a function in the Where as indicated below. Not sure how this would work. Has anyone tried something like this? Dim query = From part In xmlDoc... Assmebly > _ Where part . >.Value > 0 And IsStocked (part..Value) = False _ Select part..Value Public Function IsStocked( ByVal number As String ) As Boolean '...Code here to check against database End Function Read More...
|
-
How can pivot records in my collection using LINQ. My collection holds following information: Code Term Percentage Return ABC 30 60 .10 ABC 30 80 .20 ABC 60 60 .08 ABC 60 80 .18 XYZ 30 60 .70 XYZ 30 80 .80 XYZ 60 60 .50 XYZ 60 80 .60 I want to convert it to: ABC .10 .20 .08 .18 AXY .70 .80 .50 .60 The terms & participations are not static data, it could grow. Thanks Read More...
|
-
I'm working on a series of views for our front-end application. We desire to use XML to managed/transfer the data across the various layers, using XElements to binding and manipulate the data. I noticed a memory leak in one of our views that refreshed it's XElement datacontent whenever the application's context changes. So I did a little investigation... I created an application that binds to an XElement, and I force a context change (this requires that the window binds to a different XElement instance Read More...
|
-
Hey all, I've decided to start doing some work on my homepage again, adding some new features, etc, so I made my database changes, tried updating my EDMX data file, but it wouldn't have it, so I just deleted it and re-created it. Works fine on all pages except one. On this one page I get this error on page load: The number of members in the conceptual type 'cl_mainsiteModel.cyberlane_clients' does not match with the number of members on the object side type 'dev.Models.cyberlane_clients'. Make sure Read More...
|
-
Hello everybody. can you please help me out with this? I need to filter the result from a linq2sql statement with a string, such as "Active =1". Here is my current code: Code Snippet Dim ps As String = UserPermission( "Task" ) 'returns a where clause string Dim dcx As New MainBaseDataContext Tasks = From t In dcx.Tasks. Where (ps ) This doesn't work. The compiler complains that no overloaded version of 'Where' accepts this number of arguments. My Goal: UserPermission is a function that looks up different Read More...
|
-
Dear Linqs, I have a problem unboxing som entities: I have a set of weakly typed entities (IQueryable). Because I need to filter them, I need to use a .Join<>() on them. To do that, I need to use .Cast<>() on them to yield a joinable interface on each of the entities. Afterwards I need to call, for other reasons, DynamicQuery.Where(), and since it doesn't accept boxed entities, I have to undo the boxing. So the question is, is there a way to unbox the entities when I know the type only at runtime, Read More...
| |
|