/// <summary>
        /// Create a new instance of type T.
        /// </summary>
        /// <returns></returns>
        public virtual T CreateInstance()
        {
            T entity = Activator.CreateInstance <T> ();

            GetTable.InsertOnSubmit(entity);
            return(entity);
        }
 public void Add(T entity)
 {
     if (!Exists(entity))
     {
         GetTable.InsertOnSubmit(entity);
     }
     else
     {
         Update(entity);
     }
     SaveAll();
 }
        }//End Repository Constructor

        public OperationResult AddItem(T entity)
        {
            OperationResult opResult = OperationResult.GetInstance();

            try
            {
                GetTable.InsertOnSubmit(entity);

                this._dataContextFactory.SaveAll();
                opResult.ObjectId = PrimaryKeyName;
            }
            catch (Exception ex)
            {
                opResult.IsFailed     = true;
                opResult.ErrorMessage = ex.Message + ex.StackTrace;
            }
            return(opResult);
        }
 /// <summary>
 /// Add the entity to DB
 /// </summary>
 /// <param name="entity">DB entity</param>
 /// <returns>bool</returns>
 public bool Add(GenericEntityType entity)
 {
     if (entity == null)
     {
         _Logger.Error(typeof(GenericEntityType).Name + " is null to ADD!");
         return(false);
     }
     try
     {
         GetTable.InsertOnSubmit(entity);
         if (_Flag)
         {
             _DataContext.SubmitChanges();
         }
         return(true);
     }
     catch (Exception e)
     {
         _Logger.Error(typeof(GenericEntityType).Name + " could not be ADDED -- " + e);
         return(false);
     }
 }
 public void Create(T entity)
 {
     GetTable.InsertOnSubmit(entity);
 }
Esempio n. 6
0
 /// <summary>
 /// Inserts the specified obj.
 /// </summary>
 /// <param name="obj">The obj.</param>
 public void Insert(T obj)
 {
     GetTable.InsertOnSubmit(obj);
 }
Esempio n. 7
0
 public void MarkForAdd(T entity)
 {
     GetTable.InsertOnSubmit(entity);
 }