Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 501405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:11:11+00:00 2026-05-13T06:11:11+00:00

I’m new to ADO.net data services (and to .net in general too..), I’m having

  • 0

I’m new to ADO.net data services (and to .net in general too..), I’m having this project where I need to setup a data service to read and write to a database with nHibernate, I’ve created the service:

[WebGet]
    [SingleResult]
    public Factory Factories(int Id)
    {
        try
        {
            Factory[] results = this.CurrentDataSource.Session.Linq<Factory>().Where(g => g.Id.Equals(Id)).ToArray();
            return results[0];
        }
        catch (Exception ex)
        {
            throw ex;
        }        

And I’ve created a test for the service:

[Test]
        public void CanReadFactoryDataService()
        {
            DataServiceContext ctx = new
                  DataServiceContext(new Uri("http://localhost:1413/DataService.svc"));
            var Factories = ctx.Execute<Factory>(
                  new Uri("Factories?Id=54", UriKind.Relative));
            Assert.IsNotNull(Factories);
            Factory factory = Factories.First<Factory>();
            {
                Console.WriteLine(factory.NAME);
            }

When I run the service with the browser (eg: http://localhost:1413/DataService.svc/Factories?Id=54), the service returns:

<Factories p1:type="ADODS.Core.Factory">
<FactorY_CODE>abc</FactorY_CODE>
<NAME>Nameds</NAME>
<ADDRESS>Reinhardt strasse</ADDRESS>
<COMPENSATION_MODEL p1:null="true"/>
<B_CODE p1:null="true"/>
<Id p1:type="Edm.Int32">54</Id>
</Factories>

But when I run the unit test I’m getting this exception:

TestCase 'Tests.DataServicesTests.CanReadFactoryDataService'
failed: System.InvalidOperationException : La secuencia no contiene elementos (The sequence contains no elements)
    en System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
    H:\ADODS\tests\ADODS.Tests\ADODS.Web\DataServicesTests.cs(22,0): en Tests.DataServicesTests.CanReadFactoryDataService()

I debugged the project, so the test connects to the service and the service returns the data, but

is there anything else I should do to convert the xml data into the actual object when I receive it?

I did a test, with a string object instead of a Factory and it worked, the problem seems to be with my classes. Am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:11:11+00:00Added an answer on May 13, 2026 at 6:11 am

    Finally I solved it:
    I Added a Service reference (Wich I hadn’t done), and changed the test to:

    [Test]
            public void CanReadFactoryDataService()
            {
                ServiceReference1.DataServiceContext ctx = new
                       ServiceReference1.DataServiceContext(new Uri("http://localhost:1413/DataService.svc"));
                var factories= ctx.Execute<Factory>(
                      new Uri("Factories?Id=54", UriKind.Relative));
                Assert.IsNotNull(factories);
                Factory factory = factories.First<Factory>();
                {
                    Console.WriteLine(factory.ADDRESS);
                }
    
            }
    

    And now it passes the test:

    Reinhardt strasse
    
    1 passed, 0 failed, 0 skipped, took 3.48 seconds (NUnit 2.5.2).
    

    Now I think that was easy, but when you don’t know, it’s hard…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.