How do you use CSLA 3.5 without Dling

How do you use CSLA 3.5 without Dling

Old forum URL: forums.lhotka.net/forums/t/4461.aspx


GeorgeG posted on Wednesday, March 05, 2008

We would like to use csla 3.5 without the dling part. How do we that using ptracker project fetch

using (var ctx = ContextManager<ProjectTracker.DalLinq.PTrackerDataContext>.GetManager(ProjectTracker.DalLinq.Database.PTracker))
      {
        // get project data
        var data = (from p in ctx.DataContext.Projects
                    where p.Id == criteria.Value
                    select p).Single();
        LoadProperty<Guid>(IdProperty, data.Id);
        LoadProperty<string>(NameProperty, data.Name);
        LoadProperty<SmartDate, System.DateTime?>(StartedProperty, data.Started);
        LoadProperty<SmartDate, System.DateTime?>(EndedProperty, data.Ended);
        LoadProperty<string>(DescriptionProperty, data.Description);
        mTimestamp = data.LastChanged.ToArray();

        // get child data
        LoadProperty<ProjectResources>(ResourcesProperty, ProjectResources.GetProjectResources(data.Assignments.ToArray()));
 }

Is the following correct without using dling?
using (SqlConnection cn = new SqlConnection(Database.PTrackerConnection))
      {
        cn.Open();
        using (SqlCommand cm = cn.CreateCommand())
        {
          cm.CommandType = CommandType.StoredProcedure;
          cm.CommandText = "getProject";
          cm.Parameters.AddWithValue("@id", criteria.Id);

          using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
          {
            dr.Read();
            LoadProperty<Guid>(IdProperty, dr.GetGuid("Id"));
            LoadProperty<string>(NameProperty, dr.GetString("Name"));
            LoadProperty<SmartDate, System.DateTime?>(StartedProperty, dr.GetSmartDate("Started", _started.EmptyIsMin));
            LoadProperty<SmartDate, System.DateTime?>(EndedProperty, dr.GetSmartDate("Ended", _ended.EmptyIsMin));
            LoadProperty<string>(DescriptionProperty, dr.GetString("Description"));
            dr.GetBytes("LastChanged", 0, _timestamp, 0, 8);

            // load child objects
            dr.NextResult();
            LoadProperty<ProjectResources>(ResourcesProperty,
                ProjectResources.GetProjectResources(dr));
               
          }
        }
      }

Thanks

ajj3085 replied on Wednesday, March 05, 2008

That's the basic jist of it.

Copyright (c) Marimer LLC