Dotnetinfo’s Weblog

Just another WordPress.com weblog

Silverlight – RIA – Sybase without Entity Framework

Posted by dotnetinfo on November 13, 2009

I am in the process of learning RIA with Silverlight. I like the Entity Framework but it wont work for my sybase. At last i found an article  http://msmvps.com/blogs/deborahk/archive/2009/11/05/silverlight-ria-services-and-your-business-objects.aspx

that helped me to create domain objects and connect directly to database. The change i made mainly in domain layer

public static List<SomeData> GetData()
        {
            DataSet dsSome;
            List<SomeData> SomeList = new List<SomeData>();
            try
            {
  //using Entlib you can use any database
                DAL.Database db = DAL.DatabaseFactory.CreateDatabase(“Use Connection String”);              
                dsSome= db.ExecuteDataSet(CommandType.StoredProcedure, “Query’”);
                foreach (DataRow SomeRow in dsSome.[1].Rows)
                {
                    SomeData s = new SomeData ();
                    s.Name = SomeRow ["Name"].ToString();
                    s.Age = SomeRow ["Age"].ToString();
                    SomeList.Add(SomeData);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

         
            return SomeList;
        }

public class SomeData
    {
        [System.ComponentModel.DataAnnotations.Key()]
        public string Name{ get; set; }    
        public string Age{ get; set; }               
    }

In Service Layer
public IEnumerable<SomeData> GetSomeData()
        {
            return Customers.GetData();
        }

In Main.XAML add another grid to display the value

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.