Linq To Xml & Add A Targetnamespace As The File

Jan 11, 2010

I've got a schema for a file which specifies some repeating data. I add a targetnamespace as the file is to be used through biztalk. I am attempting to create an xml file using linqtoxml but cannot add my namespace prefix to any of my repeating/complex elements.

[Code]...

View 1 Replies


ADVERTISEMENT

Reading From XML File Using LiNQ?

Feb 21, 2010

Im starting a project that needs to read data from some sort of table, the best way i can think of storing this data was xml as its not a large amount. The xml file i have is.

<House>
<Rooms>
<Room>Dining/Living Room</Room>

[Code].....

All i want to do is query the xml with the Room name and return the Temp and Air values. I have read that there are many ways to read xml files and tbh its confused me a bit, but the LINQ method seems to be easier than the others but still having issues. Is it possible to give me some guidance of a snippet of code that will work the the above xml to populate a simple textbox upon clicking a button.

View 5 Replies

Using Linq To Create An XML File?

Jan 5, 2010

I have a datatable with the following fields:

SampleID varchar(50)
PreWeight varchar(50)
Validated char(1)

[code].....

View 1 Replies

LINQ To XML To Create Complex XML File?

Feb 9, 2012

I would like to know if there is any simple/fast way to create a complex XML file, when I say complex, I mean more than 20 elements encapsulated. Although this is VB.net,unfortunately literals will not work in this case

View 2 Replies

2010 : Save XML File Using Linq?

Sep 18, 2010

I need to create an application that is able to modify the XML elements value.I have an XML file which was created by another to be used for flash movie which has the following layout:

<?xml version="1.0" encoding="utf-8"?>
<games>
<game>
<gameName>Cowboy</gameName>

[code]....

As you can see there is this string "™" on <gd02>. My question is, whenever I save the file, the code changed to "TM" which is fine for most cases. But I need it to stay the same because apparently flash will not display the superscript "TM" if not using the code. How can I do this?

View 6 Replies

.net - Saving The Result Of A Linq Query To An XML File?

Nov 16, 2010

Here is the original xml file

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<setup>
<cap>33</cap>
</setup>

[Code]...

View 2 Replies

C# - Reading Text File With Linq With 2 Patterns?

Jul 22, 2011

I need to read a text file like this

MyItemName = Description @ MoreInfo

Now I need to convert this 3 fields in to a table. using the '=' and '@' as pattern.

View 2 Replies

VS 2008 - Parsing Large XML File Using LINQ

Dec 27, 2010

I have one large XML file from one of our vendor and I am trying to pars it using Linq but it looks some wrong logic I am using.

This is xml file:
HTML
<Psw xmlns="http://localhost">
<exid>20</exid>
<Mes><Me>
<doc><ps>
<ghder> .....

The code I am trying:
Dim doc As XDocument
doc = XDocument.Load(TextBox1.Text)
Dim qList = (From xe In doc.Descendants.Elements("ghder") _
Select New With { _
.mid = xe.Element("MId").Value, _
.cdate = xe.Element("cD").Value _
' As well I need to get the value for pn child attribute }).FirstOrDefault
MsgBox(qList.mid)

Error for DBNull ' Object reference not set to an instance of an object.

View 6 Replies

LINQ To SQL And The DBML File / Multiple Database Development

Aug 11, 2009

I have a WPF application that uses a SQL2008 database. I have a copy of the database on a laptop and on my home machine. My application is versioned using SVN and I am obviously able go from the work laptop to the home machine and update/commit as required to ensure I am using the latest code for the application.However the database is a different story in that any change I make I create a backup and then transfer the backup to the other machine etc. This way I get the data and the changes made on each system. In order to do this the database connection using a different connectionstring and I change a setting in my app to use a different connection based on my location.

I have now started to use LINQ to SQL and DBML files in my application, and finally getting to the question, I don't know how I can change the connectionstring it uses in code so it will use the correct database in the DBML.Also, is there a better way to transfer the database so I don't need to do the backups and restores? The only reason why I have not versioned the Schema is because I am not sure how that would handle my data as this is key to my development, ie various environment settings etc are stored in the DB and brought through at runtime.

View 5 Replies

Loading A Xml Document From A File Built Use Linq.Xelement

Jan 11, 2012

I'm trying to load in a xml file that was build using another windows form, but when I try the xml document I get the following error: Name cannot begin with the '%' character, hexadecimal value 0x25. Line 10, position 13.[code]

View 3 Replies

VS 2008 Could Not Load File Or Assembly System.xml.linq

Nov 17, 2009

I release an application and one of the end-users is telling me that they get this message:

See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Das System kann die angegebene Datei nicht finden.

[Code]....

The way that reads to me, there is a problem with their .net framework? Am I correct, or is there a problem with my code? I can't reproduce the problem, and many other people use the application with no problems.

View 3 Replies

.net - ActiveRecord Linq/NHibernate Linq Not Building Query Completely?

Jul 14, 2011

given this function:

Public Function Search(ByVal StartIndex As Integer, _
ByVal MaxResults As Integer, _
ByVal AccountNumber As String, _
ByVal LastName As String, _

[Code]....

instead of what I expected:

Select count(*) from remitline where lastname = "smith"

What am I doing wrong building up the where clause? I'm using Castle ActiveRecord 2.1

View 1 Replies

Performance Gain In LINQ Query Vs LINQ Stored Procedure?

Aug 6, 2009

if there is that much of a performance gain in running a LINQ stored procedure versus a LINQ query?

View 1 Replies

Getting The Data From 3 Table In Linq And Produce The CSV File And Send The Mail

Jan 19, 2011

I am using window programming in visual studio(2008) and i am using LINQ and need to get the data from three table's column e.g A table's 1st column(x),b table's 2nd column(y) and c's table third column(z), and then i have to produce the excel sheet(CSV file).I want to get the table's data in string format in visual studio and then produce the excel sheet.I don't want to use Store procedure and grid view in my program.

View 5 Replies

Linq To Entities. GetPropety(name).GetValue Not Recognised By Linq?

Apr 20, 2011

I have a listbox on my xaml form that I bound to a List(Of MyType) property. I populated this list like so:

Dim fields As List(Of CheckableFields) = New List(Of CheckableFields)
Using context As ITIPEntities = New ITIPEntities()
Try[code]....

Now I'm at the point where the user selects the fields they want included in a report and I need to iterate over the required fields. This is my linq query:

For Each checkedField In _requiredFields
If checkedField.IsChecked Then
If checkedField.FieldData IsNot Nothing AndAlso checkedField.FieldData.Trim IsNot String.Empty Then[code].....

View 1 Replies

How To Get Lamda In LINQ To Actually Filter For Dynamic Linq

Sep 10, 2009

Example-I have a person class

Public Class Person
Private _fname As String
Public Property Fname() As String

[Code]...

View 2 Replies

LINQ Query Using The Dynamic LINQ Library?

Mar 31, 2011

Forgive my ignorance on this.I have this LINQ Query:Dim ngBikersDataContext As New CarBikeWalkDataContext

bikersList = (From c In ngBikersDataContext.Reg_Bikers _
Order By c.L_Name _
Select New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _

[Code]...

with the error "Overload resolution failed because no accesible 'Select' accepts this number of arguments."
Over the "NEW" I get an error " ')'expected."

View 1 Replies

"System.ArgumentException: An Item With The Same Key Has Already Been Added." When Trying To Order An In-memory LINQ Query By A LINQ Association?

Jan 27, 2011

We are doing a query against an in-memory collection of LINQ data objects. The wrinkle is that we are ordering by a column in a related table whose records have not necessarily been loaded yet (deferred loading:)

Dim oPkgProducts = _
From b In oBillPkg.BillProducts _
Where b.Successful.GetValueOrDefault(Common.X_INDETERMINATE) = _

[code]....

View 1 Replies

.net - Linq Expressions With Linq To Entities?

Feb 28, 2012

The pattern I'm trying to avoid is checking if a string (normally a control's text value) is null/empty, and if it is, comparing it using Contains to a field in my data. Obviously the field isn't hard-coded into my extension, neither is the object type.What I've got works perfectly in Linq to Objects, but I get the generic run-time error "LINQ to Entities does not recognize the method 'System.String Invoke(GenericQueryHelper.Customer)' method, and this method cannot be translated into a store expression." when using an entity framework model.

Here's what I have:

<System.Runtime.CompilerServices.Extension()>
Public Function CompareAndFilter(Of T)(source As System.Linq.IQueryable(Of T), expressionField As System.Linq.Expressions.Expression(Of System.Func(Of T, String)), compareTo As String)

[code]....

I want my usage to look something like this:

Dim results = repository.Customers.CompareAndFilter(Function(c) c.FirstName, searchText)

I do need to get this running against a SQL database really, as it is filtering results, so I don't want to be doing that in memory.

View 2 Replies

C# - Convert Code LINQ To SQL In C # LINQ To SQL In .net?

Jun 27, 2012

How can I convert this code LINQ to SQL in C # LINQ to SQL in Vb.net

[Code]...

View 2 Replies

LINQ To SQL - Add In Row_Number To A LINQ To SQL Query?

Aug 31, 2011

How do I add ROW_NUMBER to a LINQ query or Entity? How can I convert this solution to VB.NET?

[Code]...

I'm having trouble porting that last line. I have been unable to locate a VB.NET example. I'm actually not looking for any paging functionality like the example provides, just good old-fashioned Row_Number(Order By X) row index.

View 1 Replies

Convert An Object System.Data.Linq.DataQuery To System.Linq.IQueryable?

Oct 21, 2009

How can I convert an object of type System.Data.Linq.DataQuery to System.Linq.IQueryable?I'm working with Visual Basic/Silverlight, and the source code of my query is as follows:

Public Function Get_Cli_Pag() As IQueryable(Of V_Cliente_Pagare)
Dim Qry = From P In Me.Context.Pagares Join C In Me.Context.Codigos On C.Codigo

[code]....

View 1 Replies

VS 2010 Upgrade From 2008 To 2010 - Now LINQ - IntelliSense Is Not Working For LINQ Stuff

Apr 20, 2010

I just upgraded a project from VB 2008 to VB 2010. Before, the project did not use LINQ. I have started implementing it. So, I have updated the target framework from 2.0 to 3.5, and added a reference to System.Core, and imported the namespace System.LINQ to the entire project and also imported System.Data.LINQ into the form I'm working with (because it was not available in the list for Imported Namespaces in the references tab).

It's not throwing any errors now, but my IntelliSense is not working for LINQ stuff.

For example... I write this:

[CODE]....................

Then, if I type S. on the next line, the IntelliSense doesn't grab what it should for S (Only get Equals, GetHashCode, GetType, ReferenceEquals, and ToString, instead of the options I should get like Count, First, FirstOrDefault, etc...). If I Type S.First. then its the same thing, no IntelliSense that lists the available fields for S, just the standard options (Equals, GetHashCode, GetType, ReferenceEquals, and ToString). I should be seeing my column names in my table when I type S.FirstOrDefault.

So any ideas what is going on? When I type the code, for example, MessageBox.Show(S.FirstOrDefault.FirstName), it works perfectly. But it doesn't change the casing of the text (so it would read s.firstordefault.firstname) and no intellisense while doing it. But no errors. BTW - Everything works perfectly when creating a NEW VS 2010 application, it's just my projects upgraded from Visual Basic 2008 that have this issue.

View 2 Replies

LINQ Query Is Enumerated - Turn On Some Kind Of Flag That Alerts Me Each Time A LINQ Query Is Enumerated?

Sep 22, 2009

I know that LINQ queries are deferred and only executed when the query is enumerated, but I'm having trouble figuring out exactly when that happens.Certainly in a For Each loop, the query would be enumerated.What's the rule of thumb to follow? I don't want to accidentally enumerate over my query twice if it's a huge result.

For example, does System.Linq.Enumerable.First enumerate over the whole query? I ask for performance reasons. I want to pass a LINQ result set to an ASP.NET MVC view, and I also want to pass the First element separately. Enumerating over the results twice would be painful.It would be great to turn on some kind of flag that alerts me each time a LINQ query is enumerated. That way I could catch scenarios when I accidentally enumerate twice.

View 3 Replies

Converting Linq To C# Linq?

Feb 22, 2012

I recently switched from VB to C# and have, for the most part, been able to make the transition without too much trouble. Currently I am working on converting a VB.Net program into C# and am having trouble with a couple of code blocks that include Linq.

This is one of the VB.Net lines of code that I am having trouble with:

I have tried to do the same thing in C# like this:

I am getting a compile error on the dt, which says Could not find an implementation of the query pattern for source type 'System.Data.DataTable'.'GroupBy' not found. VS also has issues with the whole into Emailers = group;

I have tried to get this right using examples from my search but have not been able to get it right.

View 2 Replies

Linq .Where With An OR Instead Of An AND?

Jul 28, 2009

suppose I wanted to make a function that returned a list of people based on 2 criteria ... FirstName = 'Ed' Or LastName = 'Smith'.The key here being the OR. If I do something like the following:

dim qry = From p in db.Person select p.FirstName, p.LastName
qry = qry.Where(Function(p) p.FirstName = 'Ed')
qry = qry.Where(Function(p) p.LastName = 'Smith')

[code].....

View 7 Replies

VB Linq To C# Linq?

Oct 19, 2011

convert it to C# equivalent

Dim dtData As DataTable = Session("Data")
Dim aFilters = From oRow In dtData _
Where oRow(i_oColumn.BaseColumnName) IsNot DBNull.Value _

[Code].....

View 1 Replies

Way To Use Linq

Jul 6, 2011

My friend told me some linq and mysql.

I not know what is LINQ.

is dll?

is addins for visual studio?

where do i download?

View 2 Replies

XML To SQL Using Linq?

Sep 22, 2010

I am having some difficulties with sending XML data to SQL using Linq.I have been following the tutorial link below, however my XML data doesn't contain a root value like <order number> to go through each of the XML data. There is no unique reference as part of the <quote> information.[URL]..

Is there a way I can submit the changes to SQL using the <reference> field as the unique field even though it is not related to <quote>?

[Code]...

View 9 Replies

.net - Converting VB Linq To C#?

Apr 12, 2011

I'm in the process of teaching myself C# by converting an existing project and am stuck converting the following vb linq code:

Dim outStuff = From tt In (From t In Products.SelectMany(Function(p) If(p.tags IsNot Nothing, p.tags, New ObservableCollection(Of TagModel)))
Group By tagName = t.name,
v = (Aggregate p In Products Where If(p.tags IsNot Nothing, p.tags.Contains(t), Nothing) Into Sum(p.views)),
nl = (Aggregate p In Products Where If(p.tags IsNot Nothing, p.tags.Contains(t), Nothing) Into Sum(p.num_likes))

[Code]...

var x = Products.SelectMany(p => (p.tags != null) ? p.tags : new ObservableCollection<TagModel>());
var tags = from t in x group t by t.name into g select new { tagname=g.First().name};

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved