Solved

How I can return string, int, or bool from a Domain Service

Posted on 2010-09-14
9
2,616 Views
Last Modified: 2013-11-12
I´m using Visual Studio 2010, Silverligh 4.
How I can return string, int, bool from a Domain Service, once that the return always is  'System.ServiceModel.DomainServices.Client.InvokeOperation<???>.

Error      1      Cannot implicitly convert type 'System.ServiceModel.DomainServices.Client.InvokeOperation<int>' to 'int'

[Invoke]
public int InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
{
    NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
    return _NFe_C_emitBLL.Inserir(nFe_C_emit);
}

Thanks
0
Comment
Question by:Plexo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 33679210
[Invoke]
public int InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
{
    NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
    return _NFe_C_emitBLL.Inserir(nFe_C_emit).Value;
}
0
 

Author Comment

by:Plexo
ID: 33682469
It not accepts  return _NFe_C_emitBLL.Inserir(nFe_C_emit).Value;
Something are returning, But I cant convert.

look the error:

Cannot implicitly convert type 'System.ServiceModel.DomainServices.Client.InvokeOperation<int>' to 'int'
0
 

Author Comment

by:Plexo
ID: 33682656
It not accepts  return _NFe_C_emitBLL.Inserir(nFe_C_emit).Value;
Something are returning, But I cant convert.

look the error:

Cannot implicitly convert type 'System.ServiceModel.DomainServices.Client.InvokeOperation<int>' to 'int'

(XAML.cs)
        private void btnIncluir_Click(object sender, RoutedEventArgs e)
        {
            pNFe_C_emit("I", 1000, "78749991000105", "35965355904", "Plexo Informática Ltda", "Plexo");
        }

(DOMAIN SERVICE)
        [Invoke]
        public void InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
        {
            NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
            _NFe_C_emitBLL.Inserir(nFe_C_emit);
        }

(BLL)
        public int Inserir(NFe_C_emit _NFe_C_emit)
        {
            db.AddToNFe_C_emit(_NFe_C_emit);
            db.SaveChanges();
            return _NFe_C_emit.ID_Plexo;
        }
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 33683179
when you tried my code what is the error it gave ??
0
 

Author Comment

by:Plexo
ID: 33683848
Hi gauthampj

When I tried your code, I had the following error:

'int' does not contain a definition for 'Value' and no extension method 'Value' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

        [Invoke]
        public int InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
        {
            NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
            return _NFe_C_emitBLL.Inserir(nFe_C_emit).Value;
        }

    public class NFe_C_emitBLL
    {
        private static NFeEntities db = new NFeEntities();
        public int Inserir(NFe_C_emit _NFe_C_emit)
        {
            db.AddToNFe_C_emit(_NFe_C_emit);
            db.SaveChanges();
            return _NFe_C_emit.ID_Plexo;
        }


0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 33683940
which line did you say the error was on.. can you post just that line ?
0
 

Author Comment

by:Plexo
ID: 33688027


Hi gauthampj
The error happens in Highlights line.
Domain Service
 [Invoke]
        public int InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
        {
            NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
           return _NFe_C_emitBLL.Inserir(nFe_C_emit);
       }

Class BLL
 public class NFe_C_emitBLL
    {
        private static NFeEntities db = new NFeEntities();
        public int Inserir(NFe_C_emit _NFe_C_emit)
        {
            db.AddToNFe_C_emit(_NFe_C_emit);
            db.SaveChanges();
            return _NFe_C_emit.ID_Plexo;
        }
    }
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 33689703
can you post the client code that is calling this service ?
i think that is where your error

you calling code should be something like

[Invoke]
public string GetInt()
{
   return 0;
}

and then

context.GetInt(new Action>(GetIntCompleted), null);

private void GetIntCompleted(InvokeOperation args)
{
   //your int is args.Value
}


0
 

Author Closing Comment

by:Plexo
ID: 33697941
Thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question