.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Returning a DataTable as List in WCF with WsHttpBinding

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net
  • Would it be better in terms of payload, if I return a datatable as a List<DataRow> from a WCF method? I have WsHtppBinding for my WCF. I am expecting the datatable to contain 5,000 to 10,000 records.
  • Also, how can I test the difference in payload sizes when returning a DataTable Vs List<DataRow>?


View Complete Post

More Related Resource Links

Transferring of DataTable Vs its List for a WCF?


I am trying to see if returning a DataTable containing 5000 records would be faster if I return instead a List<DataRow> collection from the WCF method. May be the List<DataRow> will have a smaller payload that that of original DataTable when sent via WCF ?



Conversion of List to DataTable and ViceVersa


hi ,

           Iam having a requirement where I wil get datatable or Dataview from the DataAccessLayer I need to convert them into GanaricList of entites and ViceVersa from GenericList to Datatable or DataView.

             I tried it but I cant. Can anybody help me out.

who to load DataRow to DataTable



Who can I copy data from DataRow[] to DataTable....

DataRow[] TempDataRowFilter;



DataTable TempFilterTable = new DataTable();
TempFilterTable.LoadDataRow(TempDataRowFilter, true);

It is error why ?         

How to handle null while converting from my datatable to List<> using LINQ


I am converting my datatable to LISt using LINQ
how do I handle nulls coming from database

List<Port> portDetails = new List<Port>();
DataTable dt = ds.Tables[0];               
portDetails = (from q in dt.AsEnumerable()
select new Port
PortCode = q.Field<string>("Code"),
ExtCode = q.Field<string>("Nb"),
Name = q.Field<string>("Name"))

In the above query if Code is null I do not want property
portcode to be set to the value it should only set if it is
not null or not blank 
PortCode = q.Field<string>("Code"),

What should be syntax
I was trying somethign like this which doesnt work
Portcode = q.Field<bool>("Code") == null ? null : q.Field<bool>("Code")


Error calling WCF service that is returning list.".Debugging resource strings are unavailable ......

Ok.this is just making me frustrated... Here is step by step of what I am trying to do (& not able to) 1. I am calling WCF service hosted in a SharePoint 2010 site from a silverlight app in same domain (So no cross doman I guess). 2. I use Linq to Sharepoint for querying the DB. 3. I am having a list "machines" in Sharepoint 2010 that is having a lookup column from Other list called "part" 4. My WCF method GetAllMachines() works perfectly well when it skips the lookup column "partname" & returns List of type machineitem. 5. But problem occurs when I add machineitemobject.parts.partsname in my Linq to Sharepoint query . My service gives the error not found Async_ExceptionOccurred] Arguments: Debugging resource strings are unavailable." 6. Note that return type of my Method is List<machinesitem> 7. The point to note here is that I use SPMETAL tool to generate the LINQ class that maps the lists . So When I try to query the lookup column it tries to add List item of the type class & that is what causing the error. Is it because I am not using datacontract in my service (but it returns the strings & all private members of machines list e.g. name,title etc) Is it making the attribute Serialisable will solve the error ??? I am kind of lost in it ...Plss help!!   Thanks

How to generate List Menu form the DataTable

Hi all,This is my c# code.public partial class HorizontalCssMenu : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        if (!IsPostBack)        {            LoadMenu();        }    }    private void LoadMenu()    {        DataTable dtMenu = LoadData();        StringBuilder sb = new StringBuilder();        foreach (DataRow dr in dtMenu.Rows)        {            if (string.IsNullOrEmpty(Convert.ToString(dr["ParentID"]))                || Convert.ToString(dr["ParentID"]) == "0")            {                sb.AppendLine("<ul>");                sb.AppendLine("<li ID=\"" + Convert.ToString

Query Sharepoint list, rich text columns returning HTML tags

Hi! So I have an issue that maybe someone of you have encountered as well. I am querying a Sharepoint list and creating a report from the data collected from this list. This all works fine except that one of the columns in this list is of the type "Multiple lines of text" and also supports "rich text" with different fonts, sizes and so on. This has the effect that the text returned from this column is wrapped in HTML tags that specifies how the text should be formatted. Naturally I do not want this HTML code to appear in my report so for now I have used custom code to do a string.replace and replaced for example <div></div> and <br> with "". However, this column also has url references to documents and these links shows up like this "/servername/site/subsite/Gemensamma%20dokument/Mwh.docx">http://servername/site/subsite/Gemensamma%20dokument/Mwh.docx There is some sort of double reference to the document that I guess like the HTML tags are embedded in the answer from the rich text column and this is not so easy to do a string replace on because the url varies with the different document and document names. My question really is if anyone of you have done a similar report that I am doing, and have encountered this fenomen with this sharepoint column and how you did to solve this? I have tried to creat

MOSS Search Not Returning Results from A List

Hello All,   Problem: The MOSS Search is not returning results from a subsite (and list within it). It however returns results for most of the other sites in the web application. Environment: 2 Application Servers. One of these is the index and query server. The same server is also the search server for the content databases. 5 web front end servers. Other Notes: The MOSS installation has several web applications. We however have one site within it that is not returning the required results. The results that we are looking for are located in a particular list. When one searches against the items in the list, some appear and others do not. We also get results from RSS feeds that track changes to the list in the last week. Also, some of the results returned are links to the new item in the list (that is, when you click on new to create a new item). There are no search errors in the application log. The web application was recently upgraded from WSS 3.0 on a single server to MOSS 2007 in a server farm. There are no sql index errors. The WSS Search and Office Search Services are working and have been restarted. The credentials have also been re-entered. We get less than 20 errors in the crawl logs (out of close to 800k docs). I have checked the rights for the default content access account, and it has dbo rights to the content db and search db. It also has read (and now admin

Returning DataSet/Datatable from Webmethod to Javascript

I have a simple web method written in the code-behind (not a separate asmx) of a test aspx page. All it does is return a DataTable(or DataSet) both are failing, gives a blank 500 error saying "There was an error processing the request" If I switch the return variable type to String, it works fine I think my issue has to do with the version of the System.Web.Extensions, is that the assembly that actually contains the JSON communication implementation? I've read all kinds of tutorials about how it should be possible to return the DataTable to javascript and then read the properties with javascript syntax. For some reason it isn't working for me. My web extensions is imported through my web.config with the following version <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

wcf returning a list from wcf service - I have lots of locations and I want to return the locations


How is it possible to return some kind of list from a wcf serivce, this the method in my wcf service 
my interface:

    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "Locations")]
    IList<Location> GetLocations();

 public IList<Location> GetLocations()
        Pazar.Data.Repositories.LocationRepository locRepository = new Pazar.Data.Repositories.LocationRepository();
        return locRepository.GetRootLocations().ToList<Location>();

and this how my GetRootLocations looks like, It returns IQueryable, I wounder if I can maybee return Iqueryable from my svc-service?

public IQueryable<Location> GetRootLocations()
        IQueryable<Location> locations = GetAll().Where(p => !p.ID_Parent.HasValue).OrderBy(p => p.Sequence);
        return locations;

Generic List to DataTable



I have a GenericList and i want to convert that to DataTable

My code is here

Dim queryF = From FinOpeningRegisterBranch In db1.FinOpeningRegisterBranches Where FinOpeningRegisterBranch.YearID = AccountLoginYearID.ToString And FinOpeningRegisterBranch.BranchCode = getBranchCode(txtBranch.Text, Me.Context) 
objFinOpRegs = CType(queryF.ToList(), List(Of FinOpeningRegisterBranch))

I am getting Count in "objFinOpRegs". But i want to convert "objFinOpRegs " to DataTable.


WCF Service returning DataTable for silverlight client



I am creating a WCF 3.0 service which will fetch data from the database and return mostly in DataTable and DataSet format. I am building a Silverlight client for consuming this service. But what I found is Silverlight 3.0 does not support datatable or dataset. Unfortunately most of my datas are returned in the datatable format. Is there any way to consume datatable in silver light or converting datatable to generic list or LINQ before returning them? If it is possible to convert datatable to generic collection, does it possible without iteration? This is because converting hundreds of records by iterating will affect my performance.

Thanks in Advance!!!!

Best regards,
Subalakshmi Vijayarajan.

Subalakshmi Vijayarajan.

select returning a list of values seperated by commas


I’m performing a select statement that returns the primary key of all the records matching  certain criteria. Instead of the returned set having  a row for each record returned, I want to just return just  one record that consists of a text field containing all the primary keys separated by commas.


For example:

Select personID from people

Where age < 45


Instead of:

Returning a blank DataRow



Hope this is a simple one, can't get my head around it...

I have a method like

public DataRow GetItem(ENTITY_TYPE EntityType, long EntityID)

This fetches a row and returns it. Pretty simple.

However I can't test in the method to see if the row was fetched, as the method has to end with:

Data List Returning Incomplete Results


Hi All

I have a page where users can search by company name, the data list is pulled from an Excel spreadsheet hosted on the site.  I'm seeing some strange results returned, for example:

In the company field say there are the following entries:

Anns Company
Bernards Business
Company B
Dermots Domain
Property Company

If I search for "Com" I get the following returns (correct):

Anns Company
Company B
Property Company

If I search for "Der" I get my "Sorry there are no matching results" message (Incorrect)

If I search for "Ann" I get the following returns (Correct):

Anns Company

And if I search for "e" I get the following returns (Correct):

Bernards Business
Dermots Domain
Property Company

It seems random as to why it doesn't return some values, I've tried moving rows around to see if that's the problem but it makes no difference.  My range is set correctly in the spreadsheet.

When I debug the VB code behind, when I search for something that works correctly e.g. "Com" in the above example, once enter the value and click search Visual Studio begins steping into

SPQuery returning error "One or more field types are not installed properly. Go to the list settings



SPQuery is not working properly, its throwing following exception.

"One or more field types are not installed properly. Go to the list settings page to delete these fields."

Please check the code snippet below:

SPSite spsite = new SPSite("siteurl");

SPWeb site = spsite.OpenWeb();

SPList list = site.Lists["listname"];

SPQuery query = new SPQuery();

query.Query = "<Where><Eq><FieldRef Name='ServiceLevel'/><Value Type='String'>345</Value></Eq></Where>";

SPListItemCollection items = list.GetItems(query);

DataTable DataRow Value Assumed to be Number


My app reads in a .CSV file and parses it using the dAdapter.Fill(dTable) method.

This works fine and I can see the data in rows in the DataTable.

One of the fields in the .CSV file is "Customer Number".  When this value is put into the DataTable it is automatically added as a number type field.

When I try to read the DataRow value from that DataColumn I get an error because it is not a string type.


foreach (DataRow dr in myTable.Rows)






curItem.Item["CustNumber"] = <strong>dr["Customer Number"];</strong>





I have tried converting it to string and to int32 but nothing seems to work.

How do I convert it to a string?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend