Solved

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

Posted on 2010-09-14
9
2,629 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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 describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 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