WCF Ria Services complaining about key

I'm using VS2010 and SL4 to develop a Business Application.

I've created my ADO.NET Entity Data Model and added a Stored procedure (see below code). When I try and compile the solution, I get an error saying:

Error      1      The entity 'GetCarbonData2_Result' in DomainService 'EnergyDomainClass' does not have a key defined. Entities exposed by DomainService operations must have at least one public property marked with the KeyAttribute.      EnergySuiteV2


My DomainService is also attached below. Can anyone see anything wrong here?? I've been failing to build my WCF Ria services silverlight app for days now.

Thanks




USE [EnergySuiteDB]
GO
/****** Object:  StoredProcedure [dbo].[GetCarbonData2]    Script Date: 04/18/2010 17:19:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[GetCarbonData2] @CostValueWeekday MONEY,@CostValueWeeknight MONEY,@CostValueWeekend MONEY,@sTime DateTime,@eTime DateTime,@sDate DATETIME,@Meter int,@ClChRate money,@ChCap int,@CapRate money,@GasRate int,@CO2 int,@Carbon int
AS
BEGIN
CREATE UNIQUE CLUSTERED INDEX IX_TempReportDataTimestampRecordNumber_ReportData ON myTable (Date)
 

SELECT 
    
    [Date],
    CO2_data,
    Carbon_data,
    kWh_data
    
    from dbo.myTable

--------------------------------------------------------------------------------


[EnableClientAccess()]
    public class EnergyDomainClass : LinqToEntitiesDomainService<EnergySuiteDBEntities3>
    {
        public IQueryable<GetCarbonData2_Result> GetCarbonData(string sDate, string Month, string MeterInstance)
        {
            return this.ObjectContext.GetCarbonData2(0, 0, 0, Convert.ToDateTime("8:00"), Convert.ToDateTime("21:00"), Convert.ToDateTime("2010/1/1"), 42, 0, 0, 0, 0, 0, 0).AsQueryable();
        }
    }

Open in new window

LVL 1
wint100Asked:
Who is Participating?
 
OrcbighterCommented:
The short answer is that only you can answer that.
Why did you choose it in the first place?
Do those reasons still apply?
Does it fit in your environment? Is your current working solutiuon acceptible (after cleaning it up) for production?
If so, its working. Use it.

By the way, do you have the latest version of WCF Ria?
0
 
AshokCommented:
OK, i was trying to use a #temptable.

When you created DBML, did you use #temptable or actual table?

Ashok
0
 
wint100Author Commented:
I used the actual table. I set the date field as the primary key in the table, then selected the columns in the SP.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
wint100Author Commented:
OK, I've now got things working. I had to load my dummy table into the ADO.NET Data Model and map to SP to this. After changing some of the data types, the SP is now being run and the data returned.

My last problem now is this:

When the data is returned to the Silverlight app, there should be a rows for every day of the month. Using the code below, the Messagebox only shows a single row. How can I retrieve all of the rows from the SP results?

protected void ExecuteSP(string sDate,string Month,string MeterInstance)
        {
            ctx = new EnergyDomainContext();
            try
            {
                var LoadItems = ctx.Load(ctx.GetCarbonDataQuery(Convert.ToDateTime(Calendar.SelectedDate).ToLongDateString(),"4","42"));
                LoadItems.Completed+=new EventHandler(LoadItems_Completed);
            }
            catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }

        }




private void LoadItems_Completed(object sender, EventArgs e)
        {
            var dbItems = ctx.myTables;
            if (dbItems.Count == 0)
            {
                MessageBox.Show("Unable to retrieve items from the database.");
                return;
            }
            foreach (var dbItem in dbItems)
            {
                MessageBox.Show(dbItem.Carbon_data.ToString() + " " + dbItem.Date.ToString() + " " + dbItem.CO2_data.ToString());
                

            }
            

        }

Open in new window

0
 
OrcbighterCommented:
The first thing to do would be to check that more than one item is being returned.
In other words you should check that dbItems.Count is greater than one. If it is not, then there is nothing wrong with the code. The next step is to test the stored proc independently and see what that is returning.

If dbItems.Count is greater than one, then maybe the problem is in how you have declared the event handler.
0
 
wint100Author Commented:
This is my DomainService code:
public IQueryable<myTable> GetCarbonData(string sDate, string Month, string MeterInstancee)
        {
            return this.ObjectContext.GetCarbonData2(0, 0, 0, Convert.ToDateTime("8:00"), Convert.ToDateTime("21:00"), Convert.ToDateTime(sDate), 42, 0, 0, 0, 0, 0, 0, 0).AsQueryable();
            
        }

Open in new window

0
 
wint100Author Commented:
It returns a count of 1 yet my sp returns 31 when run from management studio.
0
 
wint100Author Commented:
It returns a count of 1 yet my sp returns 31 when run from management studio.
0
 
wint100Author Commented:
It returns a count of 1 yet my sp returns 31 when run from management studio.
0
 
OrcbighterCommented:
Yes, I see your DomainSAervice code.
My question was, when you run the stored procedure GetCarbonData2 in the SQLServer Query Analyser with the hard-coded values you supplied in this example, how many items are returned in the resultset?
0
 
wint100Author Commented:
If I run from SQL studio I get a full set of 31 rows.
0
 
OrcbighterCommented:
Oops, sorry about that, my screen didn'r refresh before I posted the question.
If the query retuns 31, but you are only getting a count of 1, then the problem is in the LINQ code.
It is not translating the returned resultset into the list you have supplied.
0
 
wint100Author Commented:
I tried using ilist instead of iqueryable but no joy
0
 
OrcbighterCommented:
I am a bit confused by your code:
Your function GetCarbonData has three parameters ( date, Month, and MeterInstance) but does not use them. It calls data context function GetCarbonData2(...) which has hard-coded values and returns an IQueryable resultset.
Maybe you have simplified it for the purpose of this question?

What is the declaration of the MyTable class you supplied to the IQueryable interface?
0
 
wint100Author Commented:
This is my dummy table that I use to map to Stored Procedure to a function. My 'real' SP would not return any columns in the data model designer, so I've used a dummy SP and dummy table to map things across.

The sDate, Month and Meterinstance params will be used when I get the basic framework working propaly, as yet, they are not really used but will be linked to the UI.
0
 
wint100Author Commented:
0
 
wint100Author Commented:
This is the designer code from my ADO.NET Entity
//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.EntityClient;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

[assembly: EdmSchemaAttribute()]

namespace EnergySuiteV2.Web.Models
{
    #region Contexts
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    public partial class EnergySuiteDBEntities4 : ObjectContext
    {
        #region Constructors
    
        /// <summary>
        /// Initializes a new EnergySuiteDBEntities4 object using the connection string found in the 'EnergySuiteDBEntities4' section of the application configuration file.
        /// </summary>
        public EnergySuiteDBEntities4() : base("name=EnergySuiteDBEntities4", "EnergySuiteDBEntities4")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new EnergySuiteDBEntities4 object.
        /// </summary>
        public EnergySuiteDBEntities4(string connectionString) : base(connectionString, "EnergySuiteDBEntities4")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new EnergySuiteDBEntities4 object.
        /// </summary>
        public EnergySuiteDBEntities4(EntityConnection connection) : base(connection, "EnergySuiteDBEntities4")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        #endregion
    
        #region Partial Methods
    
        partial void OnContextCreated();
    
        #endregion
    
        #region ObjectSet Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<myTable> myTables
        {
            get
            {
                if ((_myTables == null))
                {
                    _myTables = base.CreateObjectSet<myTable>("myTables");
                }
                return _myTables;
            }
        }
        private ObjectSet<myTable> _myTables;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<MeterList> MeterLists
        {
            get
            {
                if ((_MeterLists == null))
                {
                    _MeterLists = base.CreateObjectSet<MeterList>("MeterLists");
                }
                return _MeterLists;
            }
        }
        private ObjectSet<MeterList> _MeterLists;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<UtilityRate> UtilityRates
        {
            get
            {
                if ((_UtilityRates == null))
                {
                    _UtilityRates = base.CreateObjectSet<UtilityRate>("UtilityRates");
                }
                return _UtilityRates;
            }
        }
        private ObjectSet<UtilityRate> _UtilityRates;

        #endregion
        #region AddTo Methods
    
        /// <summary>
        /// Deprecated Method for adding a new object to the myTables EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddTomyTables(myTable myTable)
        {
            base.AddObject("myTables", myTable);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the MeterLists EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToMeterLists(MeterList meterList)
        {
            base.AddObject("MeterLists", meterList);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the UtilityRates EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToUtilityRates(UtilityRate utilityRate)
        {
            base.AddObject("UtilityRates", utilityRate);
        }

        #endregion
        #region Function Imports
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="costValueWeekday">No Metadata Documentation available.</param>
        /// <param name="costValueWeeknight">No Metadata Documentation available.</param>
        /// <param name="costValueWeekend">No Metadata Documentation available.</param>
        /// <param name="sTime">No Metadata Documentation available.</param>
        /// <param name="eTime">No Metadata Documentation available.</param>
        /// <param name="sDate">No Metadata Documentation available.</param>
        /// <param name="meter">No Metadata Documentation available.</param>
        /// <param name="clChRate">No Metadata Documentation available.</param>
        /// <param name="chCap">No Metadata Documentation available.</param>
        /// <param name="capRate">No Metadata Documentation available.</param>
        /// <param name="gasRate">No Metadata Documentation available.</param>
        /// <param name="cO2">No Metadata Documentation available.</param>
        /// <param name="carbon">No Metadata Documentation available.</param>
        /// <param name="iD">No Metadata Documentation available.</param>
        public ObjectResult<myTable> GetCarbonData2(Nullable<global::System.Decimal> costValueWeekday, Nullable<global::System.Decimal> costValueWeeknight, Nullable<global::System.Decimal> costValueWeekend, Nullable<global::System.DateTime> sTime, Nullable<global::System.DateTime> eTime, Nullable<global::System.DateTime> sDate, Nullable<global::System.Int32> meter, Nullable<global::System.Decimal> clChRate, Nullable<global::System.Int32> chCap, Nullable<global::System.Decimal> capRate, Nullable<global::System.Int32> gasRate, Nullable<global::System.Int32> cO2, Nullable<global::System.Int32> carbon, Nullable<global::System.Int32> iD)
        {
            ObjectParameter costValueWeekdayParameter;
            if (costValueWeekday.HasValue)
            {
                costValueWeekdayParameter = new ObjectParameter("CostValueWeekday", costValueWeekday);
            }
            else
            {
                costValueWeekdayParameter = new ObjectParameter("CostValueWeekday", typeof(global::System.Decimal));
            }
    
            ObjectParameter costValueWeeknightParameter;
            if (costValueWeeknight.HasValue)
            {
                costValueWeeknightParameter = new ObjectParameter("CostValueWeeknight", costValueWeeknight);
            }
            else
            {
                costValueWeeknightParameter = new ObjectParameter("CostValueWeeknight", typeof(global::System.Decimal));
            }
    
            ObjectParameter costValueWeekendParameter;
            if (costValueWeekend.HasValue)
            {
                costValueWeekendParameter = new ObjectParameter("CostValueWeekend", costValueWeekend);
            }
            else
            {
                costValueWeekendParameter = new ObjectParameter("CostValueWeekend", typeof(global::System.Decimal));
            }
    
            ObjectParameter sTimeParameter;
            if (sTime.HasValue)
            {
                sTimeParameter = new ObjectParameter("sTime", sTime);
            }
            else
            {
                sTimeParameter = new ObjectParameter("sTime", typeof(global::System.DateTime));
            }
    
            ObjectParameter eTimeParameter;
            if (eTime.HasValue)
            {
                eTimeParameter = new ObjectParameter("eTime", eTime);
            }
            else
            {
                eTimeParameter = new ObjectParameter("eTime", typeof(global::System.DateTime));
            }
    
            ObjectParameter sDateParameter;
            if (sDate.HasValue)
            {
                sDateParameter = new ObjectParameter("sDate", sDate);
            }
            else
            {
                sDateParameter = new ObjectParameter("sDate", typeof(global::System.DateTime));
            }
    
            ObjectParameter meterParameter;
            if (meter.HasValue)
            {
                meterParameter = new ObjectParameter("Meter", meter);
            }
            else
            {
                meterParameter = new ObjectParameter("Meter", typeof(global::System.Int32));
            }
    
            ObjectParameter clChRateParameter;
            if (clChRate.HasValue)
            {
                clChRateParameter = new ObjectParameter("ClChRate", clChRate);
            }
            else
            {
                clChRateParameter = new ObjectParameter("ClChRate", typeof(global::System.Decimal));
            }
    
            ObjectParameter chCapParameter;
            if (chCap.HasValue)
            {
                chCapParameter = new ObjectParameter("ChCap", chCap);
            }
            else
            {
                chCapParameter = new ObjectParameter("ChCap", typeof(global::System.Int32));
            }
    
            ObjectParameter capRateParameter;
            if (capRate.HasValue)
            {
                capRateParameter = new ObjectParameter("CapRate", capRate);
            }
            else
            {
                capRateParameter = new ObjectParameter("CapRate", typeof(global::System.Decimal));
            }
    
            ObjectParameter gasRateParameter;
            if (gasRate.HasValue)
            {
                gasRateParameter = new ObjectParameter("GasRate", gasRate);
            }
            else
            {
                gasRateParameter = new ObjectParameter("GasRate", typeof(global::System.Int32));
            }
    
            ObjectParameter cO2Parameter;
            if (cO2.HasValue)
            {
                cO2Parameter = new ObjectParameter("CO2", cO2);
            }
            else
            {
                cO2Parameter = new ObjectParameter("CO2", typeof(global::System.Int32));
            }
    
            ObjectParameter carbonParameter;
            if (carbon.HasValue)
            {
                carbonParameter = new ObjectParameter("Carbon", carbon);
            }
            else
            {
                carbonParameter = new ObjectParameter("Carbon", typeof(global::System.Int32));
            }
    
            ObjectParameter iDParameter;
            if (iD.HasValue)
            {
                iDParameter = new ObjectParameter("ID", iD);
            }
            else
            {
                iDParameter = new ObjectParameter("ID", typeof(global::System.Int32));
            }
    
            return base.ExecuteFunction<myTable>("GetCarbonData2", costValueWeekdayParameter, costValueWeeknightParameter, costValueWeekendParameter, sTimeParameter, eTimeParameter, sDateParameter, meterParameter, clChRateParameter, chCapParameter, capRateParameter, gasRateParameter, cO2Parameter, carbonParameter, iDParameter);
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        /// <param name="mergeOption"></param>
        /// <param name="costValueWeekday">No Metadata Documentation available.</param>
        /// <param name="costValueWeeknight">No Metadata Documentation available.</param>
        /// <param name="costValueWeekend">No Metadata Documentation available.</param>
        /// <param name="sTime">No Metadata Documentation available.</param>
        /// <param name="eTime">No Metadata Documentation available.</param>
        /// <param name="sDate">No Metadata Documentation available.</param>
        /// <param name="meter">No Metadata Documentation available.</param>
        /// <param name="clChRate">No Metadata Documentation available.</param>
        /// <param name="chCap">No Metadata Documentation available.</param>
        /// <param name="capRate">No Metadata Documentation available.</param>
        /// <param name="gasRate">No Metadata Documentation available.</param>
        /// <param name="cO2">No Metadata Documentation available.</param>
        /// <param name="carbon">No Metadata Documentation available.</param>
        /// <param name="iD">No Metadata Documentation available.</param>
        public ObjectResult<myTable> GetCarbonData2(Nullable<global::System.Decimal> costValueWeekday, Nullable<global::System.Decimal> costValueWeeknight, Nullable<global::System.Decimal> costValueWeekend, Nullable<global::System.DateTime> sTime, Nullable<global::System.DateTime> eTime, Nullable<global::System.DateTime> sDate, Nullable<global::System.Int32> meter, Nullable<global::System.Decimal> clChRate, Nullable<global::System.Int32> chCap, Nullable<global::System.Decimal> capRate, Nullable<global::System.Int32> gasRate, Nullable<global::System.Int32> cO2, Nullable<global::System.Int32> carbon, Nullable<global::System.Int32> iD, MergeOption mergeOption)
        {
            ObjectParameter costValueWeekdayParameter;
            if (costValueWeekday.HasValue)
            {
                costValueWeekdayParameter = new ObjectParameter("CostValueWeekday", costValueWeekday);
            }
            else
            {
                costValueWeekdayParameter = new ObjectParameter("CostValueWeekday", typeof(global::System.Decimal));
            }
    
            ObjectParameter costValueWeeknightParameter;
            if (costValueWeeknight.HasValue)
            {
                costValueWeeknightParameter = new ObjectParameter("CostValueWeeknight", costValueWeeknight);
            }
            else
            {
                costValueWeeknightParameter = new ObjectParameter("CostValueWeeknight", typeof(global::System.Decimal));
            }
    
            ObjectParameter costValueWeekendParameter;
            if (costValueWeekend.HasValue)
            {
                costValueWeekendParameter = new ObjectParameter("CostValueWeekend", costValueWeekend);
            }
            else
            {
                costValueWeekendParameter = new ObjectParameter("CostValueWeekend", typeof(global::System.Decimal));
            }
    
            ObjectParameter sTimeParameter;
            if (sTime.HasValue)
            {
                sTimeParameter = new ObjectParameter("sTime", sTime);
            }
            else
            {
                sTimeParameter = new ObjectParameter("sTime", typeof(global::System.DateTime));
            }
    
            ObjectParameter eTimeParameter;
            if (eTime.HasValue)
            {
                eTimeParameter = new ObjectParameter("eTime", eTime);
            }
            else
            {
                eTimeParameter = new ObjectParameter("eTime", typeof(global::System.DateTime));
            }
    
            ObjectParameter sDateParameter;
            if (sDate.HasValue)
            {
                sDateParameter = new ObjectParameter("sDate", sDate);
            }
            else
            {
                sDateParameter = new ObjectParameter("sDate", typeof(global::System.DateTime));
            }
    
            ObjectParameter meterParameter;
            if (meter.HasValue)
            {
                meterParameter = new ObjectParameter("Meter", meter);
            }
            else
            {
                meterParameter = new ObjectParameter("Meter", typeof(global::System.Int32));
            }
    
            ObjectParameter clChRateParameter;
            if (clChRate.HasValue)
            {
                clChRateParameter = new ObjectParameter("ClChRate", clChRate);
            }
            else
            {
                clChRateParameter = new ObjectParameter("ClChRate", typeof(global::System.Decimal));
            }
    
            ObjectParameter chCapParameter;
            if (chCap.HasValue)
            {
                chCapParameter = new ObjectParameter("ChCap", chCap);
            }
            else
            {
                chCapParameter = new ObjectParameter("ChCap", typeof(global::System.Int32));
            }
    
            ObjectParameter capRateParameter;
            if (capRate.HasValue)
            {
                capRateParameter = new ObjectParameter("CapRate", capRate);
            }
            else
            {
                capRateParameter = new ObjectParameter("CapRate", typeof(global::System.Decimal));
            }
    
            ObjectParameter gasRateParameter;
            if (gasRate.HasValue)
            {
                gasRateParameter = new ObjectParameter("GasRate", gasRate);
            }
            else
            {
                gasRateParameter = new ObjectParameter("GasRate", typeof(global::System.Int32));
            }
    
            ObjectParameter cO2Parameter;
            if (cO2.HasValue)
            {
                cO2Parameter = new ObjectParameter("CO2", cO2);
            }
            else
            {
                cO2Parameter = new ObjectParameter("CO2", typeof(global::System.Int32));
            }
    
            ObjectParameter carbonParameter;
            if (carbon.HasValue)
            {
                carbonParameter = new ObjectParameter("Carbon", carbon);
            }
            else
            {
                carbonParameter = new ObjectParameter("Carbon", typeof(global::System.Int32));
            }
    
            ObjectParameter iDParameter;
            if (iD.HasValue)
            {
                iDParameter = new ObjectParameter("ID", iD);
            }
            else
            {
                iDParameter = new ObjectParameter("ID", typeof(global::System.Int32));
            }
    
            return base.ExecuteFunction<myTable>("GetCarbonData2", mergeOption, costValueWeekdayParameter, costValueWeeknightParameter, costValueWeekendParameter, sTimeParameter, eTimeParameter, sDateParameter, meterParameter, clChRateParameter, chCapParameter, capRateParameter, gasRateParameter, cO2Parameter, carbonParameter, iDParameter);
        }

        #endregion
    }
    

    #endregion
    
    #region Entities
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="EnergySuiteDBModel", Name="MeterList")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class MeterList : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new MeterList object.
        /// </summary>
        /// <param name="id">Initial value of the ID property.</param>
        public static MeterList CreateMeterList(global::System.Int32 id)
        {
            MeterList meterList = new MeterList();
            meterList.ID = id;
            return meterList;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ID
        {
            get
            {
                return _ID;
            }
            set
            {
                if (_ID != value)
                {
                    OnIDChanging(value);
                    ReportPropertyChanging("ID");
                    _ID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("ID");
                    OnIDChanged();
                }
            }
        }
        private global::System.Int32 _ID;
        partial void OnIDChanging(global::System.Int32 value);
        partial void OnIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String MeterName
        {
            get
            {
                return _MeterName;
            }
            set
            {
                OnMeterNameChanging(value);
                ReportPropertyChanging("MeterName");
                _MeterName = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("MeterName");
                OnMeterNameChanged();
            }
        }
        private global::System.String _MeterName;
        partial void OnMeterNameChanging(global::System.String value);
        partial void OnMeterNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> MeterInstance
        {
            get
            {
                return _MeterInstance;
            }
            set
            {
                OnMeterInstanceChanging(value);
                ReportPropertyChanging("MeterInstance");
                _MeterInstance = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("MeterInstance");
                OnMeterInstanceChanged();
            }
        }
        private Nullable<global::System.Int32> _MeterInstance;
        partial void OnMeterInstanceChanging(Nullable<global::System.Int32> value);
        partial void OnMeterInstanceChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String FriendlyName
        {
            get
            {
                return _FriendlyName;
            }
            set
            {
                OnFriendlyNameChanging(value);
                ReportPropertyChanging("FriendlyName");
                _FriendlyName = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("FriendlyName");
                OnFriendlyNameChanged();
            }
        }
        private global::System.String _FriendlyName;
        partial void OnFriendlyNameChanging(global::System.String value);
        partial void OnFriendlyNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String UtilityName
        {
            get
            {
                return _UtilityName;
            }
            set
            {
                OnUtilityNameChanging(value);
                ReportPropertyChanging("UtilityName");
                _UtilityName = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("UtilityName");
                OnUtilityNameChanged();
            }
        }
        private global::System.String _UtilityName;
        partial void OnUtilityNameChanging(global::System.String value);
        partial void OnUtilityNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String CO2Multiplier
        {
            get
            {
                return _CO2Multiplier;
            }
            set
            {
                OnCO2MultiplierChanging(value);
                ReportPropertyChanging("CO2Multiplier");
                _CO2Multiplier = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("CO2Multiplier");
                OnCO2MultiplierChanged();
            }
        }
        private global::System.String _CO2Multiplier;
        partial void OnCO2MultiplierChanging(global::System.String value);
        partial void OnCO2MultiplierChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String CarbonMultiplier
        {
            get
            {
                return _CarbonMultiplier;
            }
            set
            {
                OnCarbonMultiplierChanging(value);
                ReportPropertyChanging("CarbonMultiplier");
                _CarbonMultiplier = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("CarbonMultiplier");
                OnCarbonMultiplierChanged();
            }
        }
        private global::System.String _CarbonMultiplier;
        partial void OnCarbonMultiplierChanging(global::System.String value);
        partial void OnCarbonMultiplierChanged();

        #endregion
    
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="EnergySuiteDBModel", Name="myTable")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class myTable : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new myTable object.
        /// </summary>
        /// <param name="id">Initial value of the ID property.</param>
        /// <param name="date">Initial value of the Date property.</param>
        public static myTable CreatemyTable(global::System.Int32 id, global::System.String date)
        {
            myTable myTable = new myTable();
            myTable.ID = id;
            myTable.Date = date;
            return myTable;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ID
        {
            get
            {
                return _ID;
            }
            set
            {
                if (_ID != value)
                {
                    OnIDChanging(value);
                    ReportPropertyChanging("ID");
                    _ID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("ID");
                    OnIDChanged();
                }
            }
        }
        private global::System.Int32 _ID;
        partial void OnIDChanging(global::System.Int32 value);
        partial void OnIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String Date
        {
            get
            {
                return _Date;
            }
            set
            {
                OnDateChanging(value);
                ReportPropertyChanging("Date");
                _Date = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("Date");
                OnDateChanged();
            }
        }
        private global::System.String _Date;
        partial void OnDateChanging(global::System.String value);
        partial void OnDateChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> CO2_data
        {
            get
            {
                return _CO2_data;
            }
            set
            {
                OnCO2_dataChanging(value);
                ReportPropertyChanging("CO2_data");
                _CO2_data = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("CO2_data");
                OnCO2_dataChanged();
            }
        }
        private Nullable<global::System.Decimal> _CO2_data;
        partial void OnCO2_dataChanging(Nullable<global::System.Decimal> value);
        partial void OnCO2_dataChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> Carbon_data
        {
            get
            {
                return _Carbon_data;
            }
            set
            {
                OnCarbon_dataChanging(value);
                ReportPropertyChanging("Carbon_data");
                _Carbon_data = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Carbon_data");
                OnCarbon_dataChanged();
            }
        }
        private Nullable<global::System.Decimal> _Carbon_data;
        partial void OnCarbon_dataChanging(Nullable<global::System.Decimal> value);
        partial void OnCarbon_dataChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> kWh_data
        {
            get
            {
                return _kWh_data;
            }
            set
            {
                OnkWh_dataChanging(value);
                ReportPropertyChanging("kWh_data");
                _kWh_data = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("kWh_data");
                OnkWh_dataChanged();
            }
        }
        private Nullable<global::System.Decimal> _kWh_data;
        partial void OnkWh_dataChanging(Nullable<global::System.Decimal> value);
        partial void OnkWh_dataChanged();

        #endregion
    
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="EnergySuiteDBModel", Name="UtilityRate")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class UtilityRate : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new UtilityRate object.
        /// </summary>
        /// <param name="id">Initial value of the ID property.</param>
        public static UtilityRate CreateUtilityRate(global::System.Int32 id)
        {
            UtilityRate utilityRate = new UtilityRate();
            utilityRate.ID = id;
            return utilityRate;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ID
        {
            get
            {
                return _ID;
            }
            set
            {
                if (_ID != value)
                {
                    OnIDChanging(value);
                    ReportPropertyChanging("ID");
                    _ID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("ID");
                    OnIDChanged();
                }
            }
        }
        private global::System.Int32 _ID;
        partial void OnIDChanging(global::System.Int32 value);
        partial void OnIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> UtilityID
        {
            get
            {
                return _UtilityID;
            }
            set
            {
                OnUtilityIDChanging(value);
                ReportPropertyChanging("UtilityID");
                _UtilityID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("UtilityID");
                OnUtilityIDChanged();
            }
        }
        private Nullable<global::System.Int32> _UtilityID;
        partial void OnUtilityIDChanging(Nullable<global::System.Int32> value);
        partial void OnUtilityIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String UtilityName
        {
            get
            {
                return _UtilityName;
            }
            set
            {
                OnUtilityNameChanging(value);
                ReportPropertyChanging("UtilityName");
                _UtilityName = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("UtilityName");
                OnUtilityNameChanged();
            }
        }
        private global::System.String _UtilityName;
        partial void OnUtilityNameChanging(global::System.String value);
        partial void OnUtilityNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> WeekDayCost
        {
            get
            {
                return _WeekDayCost;
            }
            set
            {
                OnWeekDayCostChanging(value);
                ReportPropertyChanging("WeekDayCost");
                _WeekDayCost = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("WeekDayCost");
                OnWeekDayCostChanged();
            }
        }
        private Nullable<global::System.Decimal> _WeekDayCost;
        partial void OnWeekDayCostChanging(Nullable<global::System.Decimal> value);
        partial void OnWeekDayCostChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> WeekNightCost
        {
            get
            {
                return _WeekNightCost;
            }
            set
            {
                OnWeekNightCostChanging(value);
                ReportPropertyChanging("WeekNightCost");
                _WeekNightCost = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("WeekNightCost");
                OnWeekNightCostChanged();
            }
        }
        private Nullable<global::System.Decimal> _WeekNightCost;
        partial void OnWeekNightCostChanging(Nullable<global::System.Decimal> value);
        partial void OnWeekNightCostChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> WeekEndCost
        {
            get
            {
                return _WeekEndCost;
            }
            set
            {
                OnWeekEndCostChanging(value);
                ReportPropertyChanging("WeekEndCost");
                _WeekEndCost = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("WeekEndCost");
                OnWeekEndCostChanged();
            }
        }
        private Nullable<global::System.Decimal> _WeekEndCost;
        partial void OnWeekEndCostChanging(Nullable<global::System.Decimal> value);
        partial void OnWeekEndCostChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.DateTime> WeekDayStart
        {
            get
            {
                return _WeekDayStart;
            }
            set
            {
                OnWeekDayStartChanging(value);
                ReportPropertyChanging("WeekDayStart");
                _WeekDayStart = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("WeekDayStart");
                OnWeekDayStartChanged();
            }
        }
        private Nullable<global::System.DateTime> _WeekDayStart;
        partial void OnWeekDayStartChanging(Nullable<global::System.DateTime> value);
        partial void OnWeekDayStartChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.DateTime> WeekDayEnd
        {
            get
            {
                return _WeekDayEnd;
            }
            set
            {
                OnWeekDayEndChanging(value);
                ReportPropertyChanging("WeekDayEnd");
                _WeekDayEnd = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("WeekDayEnd");
                OnWeekDayEndChanged();
            }
        }
        private Nullable<global::System.DateTime> _WeekDayEnd;
        partial void OnWeekDayEndChanging(Nullable<global::System.DateTime> value);
        partial void OnWeekDayEndChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> ClimateChangeLevyRate
        {
            get
            {
                return _ClimateChangeLevyRate;
            }
            set
            {
                OnClimateChangeLevyRateChanging(value);
                ReportPropertyChanging("ClimateChangeLevyRate");
                _ClimateChangeLevyRate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ClimateChangeLevyRate");
                OnClimateChangeLevyRateChanged();
            }
        }
        private Nullable<global::System.Decimal> _ClimateChangeLevyRate;
        partial void OnClimateChangeLevyRateChanging(Nullable<global::System.Decimal> value);
        partial void OnClimateChangeLevyRateChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Decimal> CapacityRate
        {
            get
            {
                return _CapacityRate;
            }
            set
            {
                OnCapacityRateChanging(value);
                ReportPropertyChanging("CapacityRate");
                _CapacityRate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("CapacityRate");
                OnCapacityRateChanged();
            }
        }
        private Nullable<global::System.Decimal> _CapacityRate;
        partial void OnCapacityRateChanging(Nullable<global::System.Decimal> value);
        partial void OnCapacityRateChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String ChargeableCapacity
        {
            get
            {
                return _ChargeableCapacity;
            }
            set
            {
                OnChargeableCapacityChanging(value);
                ReportPropertyChanging("ChargeableCapacity");
                _ChargeableCapacity = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("ChargeableCapacity");
                OnChargeableCapacityChanged();
            }
        }
        private global::System.String _ChargeableCapacity;
        partial void OnChargeableCapacityChanging(global::System.String value);
        partial void OnChargeableCapacityChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String FixedRateAdditionPerc
        {
            get
            {
                return _FixedRateAdditionPerc;
            }
            set
            {
                OnFixedRateAdditionPercChanging(value);
                ReportPropertyChanging("FixedRateAdditionPerc");
                _FixedRateAdditionPerc = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("FixedRateAdditionPerc");
                OnFixedRateAdditionPercChanged();
            }
        }
        private global::System.String _FixedRateAdditionPerc;
        partial void OnFixedRateAdditionPercChanging(global::System.String value);
        partial void OnFixedRateAdditionPercChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String ShowGasAsRate
        {
            get
            {
                return _ShowGasAsRate;
            }
            set
            {
                OnShowGasAsRateChanging(value);
                ReportPropertyChanging("ShowGasAsRate");
                _ShowGasAsRate = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("ShowGasAsRate");
                OnShowGasAsRateChanged();
            }
        }
        private global::System.String _ShowGasAsRate;
        partial void OnShowGasAsRateChanging(global::System.String value);
        partial void OnShowGasAsRateChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Units
        {
            get
            {
                return _Units;
            }
            set
            {
                OnUnitsChanging(value);
                ReportPropertyChanging("Units");
                _Units = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Units");
                OnUnitsChanged();
            }
        }
        private global::System.String _Units;
        partial void OnUnitsChanging(global::System.String value);
        partial void OnUnitsChanged();

        #endregion
    
    }

    #endregion
    
}

Open in new window

0
 
OrcbighterCommented:
Ther ADO.Net entity defines five attributes ID,Date, CO2_data, Carbon_data, and  kWh_data
as types String, Decimal, Decimal, Decimal, and Decimal, respectively.

How are they defined on the database?
Without seeing your whole project (no, don't attach it), I cannot see how you generated the linq settings.
I repeat, your problem is a fundamental disconnect between the result set returned by the stored procedure and the list you are mapping it to.
Perhaps you could review the way you did it. I recommend this article as a starter:

http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx

It might provide some insight into where the disconnect might be.

0
 
wint100Author Commented:
The sp queries a table and returns those columns with a row for each day of the month.

All I have done is Create the ado.net model, added the sp and table and imported the function which maps the sp to the table.

That is it, other than the query in the domain service called getcarbondata.

Would I be better using a linqtosql class instead of the ado.net data model?
0
 
OrcbighterCommented:
Its midnight here. I am going to bed. Will ponder the solution in the batch process euphamistically referred to as "sleep".
0
 
wint100Author Commented:
I now have this working with a silverlight WCF service. Very strange as the SP call is exactly the same!? Maybe its to do withbinding to the ctx.myTable, I really don't know.

Is there any advantage to using WCF Ria services over silver enable WCF service? I don't want to be starting a new project on old tech.
0
 
wint100Author Commented:
I'm using the code below on my client side, do I need to be e.result to set the items source on my datagrid?

If so, then which eventargs should I be using, because currently using 'Eventargs e', doesn't expose a property for e.result.

You can see in the middle method(which is used in the WCF Service), the void uses getDataCompletedEventArgs e. Then e.result. Should I be doing something similar in the Load_Completed method?
protected void ExecuteSP(string sDate,string Month,string MeterInstance)
        {
            
            dbAccess.getDataCompleted += getDataCompleted;
            dbAccess.getDataAsync(Convert.ToDateTime(Calendar.SelectedDate).ToLongDateString(), Convert.ToDateTime(Calendar.SelectedDate).Month.ToString(), "42");
            ctx = new EnergyDomainContext();
            try
            {
                var LoadItems = ctx.Load(ctx.GetCarbonDataQuery(Convert.ToDateTime(Calendar.SelectedDate).ToLongDateString(), "1", "42"));


                //dataGrid1.ItemsSource = ctx.myTables; 
              LoadItems.Completed+=LoadItems_Completed;
                
            }
           catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }

        }
        private void getDataCompleted(object sender, getDataCompletedEventArgs e)
        {
            
            dataGrid1.ItemsSource = e.Result;
            foreach (var c in e.Result)
            {
             //   MessageBox.Show(c.Col1.ToString());
            }
            // e.Result is the list with all the results resturned from your SP
        }
        private void LoadItems_Completed(object sender, EventArgs e)
        {

            var dbItems = ctx.myTables;
            
            //dataGrid1.ItemsSource = ctx.myTables;

            if (dbItems.Count == 0)
            {
                MessageBox.Show("Unable to retrieve items from the database.");
                return;
            }
            


        }

Open in new window

0
 
wint100Author Commented:
Just seen you post.

I'm using Ria as it's the newer tech, and should simplify thing!?

I'd just like to keep up-to-date and use the latest offerings from MS, as it's a new project.

I'm using ria RC2, that was release 15h April.
0
 
OrcbighterCommented:
There are two axioms one should remember in programing:
(a) Never buy version 0 of anything.
(b) RC is not a production release, its a beta that is ABOUT to become a production release.

To violate these axioms is valid and can lead to an interresting life. You might get through it painlessy, and it may be faster, stronger, leaner and meaner, but it will mostly never be simpler.
0
 
AshokCommented:
So when is the production release expected?

Would it be the same case for VS 2010 Express Edition?
0
 
AshokCommented:
Another hint for learning latest RIA.

If you have access to VS 2008, use RIA with it.  RIA also works with VS 2008.

Ashok
0
 
wint100Author Commented:
WCF Service was the way to go on this
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.